This is my controller:
def addcar
@car = Car.new(params[:car])
render :action => "list"
end
this is my view:
<%(@allcars).each do |cell|%>
<p><%= link_to cell.to_s, :controller => "car", :action => "addcar", :car => cell.to_s %></p>
<%end %>
In the link_to
statement I want to pass cell.to_s
to the controller. How can I do that please? The cell.to_s
is just a string but I want it to be the name of the car object (car.Name
)
Car.new(params[:car])
expectsparams[:car]
to be a Hash ({:foo => "bar"}
). So change your code: