Try:
<%= link_to "Add to cart", {:controller => "car", :action => "add_to_cart", :car => car.id }%>
and then in your controller
@car = Car.find(params[:car])
which, will find in your ‘cars’ table (as with rails pluralization) in your DB a car with id == to car.id
More Related Contents:
- How to get a Date from date_select or select_date in Rails?
- Rails: Preserving GET query string parameters in link_to
- undefined method `stringify_keys!’ ruby on rails
- Fully custom validation error message with Rails
- What do helper and helper_method do?
- devise and multiple “user” models
- Converting camel case to underscore case in ruby
- OpenSSL::SSL::SSLError on Heroku [duplicate]
- ruby/ruby on rails memory leak detection
- How can I uninstall Ruby on ubuntu?
- Overriding id on create in ActiveRecord
- What does Rails 3 session_store domain :all really do?
- How do i work with two different databases in rails with active records?
- Using Rails Migration on different database than standard “production” or “development”
- Ruby on Rails — multiple selection in f.select
- Rails Console: reload! not reflecting changes in model files? What could be possible reason?
- How would you parse a url in Ruby to get the main domain?
- counter_cache with has_many :through
- Rails Routes – Limiting the available formats for a resource
- How can I specify a local gem in my Gemfile?
- Load lib files in production
- What is the right way to override a setter method in Ruby on Rails?
- Docker: Is the server running on host “localhost” (::1) and accepting TCP/IP connections on port 5432?
- Limit number of objects in has_many association
- Rails: How to parse date-time string into a specific time zone
- What does binding a Rails Server to 0.0.0.0 buy you?
- Capistrano and environment variables
- Rails 2 to Rails 3 : using link_to instead of link_to_remote (including remote and update)
- Rails App Not Serving Assets in Production Environment
- Ruby 1.9.2 and Rails 3 cannot open rails console