I want to pass two params that I am introducing in an input en the index view. This is what i have in the index (the style doesn´t matter):
<form action="/cars" method="GET">
<input type="text" name="from" placeholder="From" value="<%= @from %>"/>
<input type="text" name="to" placeholder="To" value="<%= @to %>"/>
<input style="color:white; border-radius: 2px; padding: 10px; margin-right: 20px; font-family: 'Montserrat', sans-serif; background-color: black; " type="submit", value="SUBMIT" />
</form>
After this, in the cars_controller I have the following:
if params[:from] && params[:to]
@cars = @cars.filter(params[:from, :to])
end
Finally in my model, i have my function that works with The:from and:to params in a specific way to filter the cars, it doesn´t matter what´s inside. My method is like the following:
def filter(from, to)
end
So the problem comes when, in the index view, I introduce the:from ant:to params by hand, press teh submit button and it returns me "wrong number of arguments (given 2, expected 1)"
@cars = @cars.filter(params[:from] , params[:to])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.