What is the difference between "form_for @ecard" and "form_for: ecard"?

I implemented a restfull controller with all the right actions and views. Currently, it works great with the new_html.erb view, which uses form_for containing a structure such as:

 <% form_for @ecard do |f| %> 

watching some textbooks, I saw that people also use structure:

 <% form_for :ecard do |f| %> 

It sounds logical .. but when I try to use <% form_for : ecard do | f | %> the resulting message goes to another action, then using <% form_for @ecard do | f | %> ..

-> html result: -> html result: So I wonder what I'm missing, the difference is in use: ecard and @ecard are obvious when I look at the generated html, but I'm still wondering what arguments are behind this! So can someone please explain what the difference is and what structure I should use? It or
+2
ruby ruby-on-rails
source share
1 answer

Marco

This has been answered on the site before:

instance variable versus ruby ​​symbol on rails (form_for)

I hope this clears.

+2
source share

All Articles