I’m using rails 3 and this is how I’ve set up my link_to in my view
<%= link_to ('add',
:url => {:controller => 'favourite_companies', :action =>'create',
:company_id=>@company.id,
:company_name=>@company.company_name, :remote => true}) %>
When I click it, the page refreshes and nothing happens.
I’ve added <%= csrf_meta_tag %> and all javascript files.
In the controller, the function looks like this:
def create
@favorite_list =
FavouriteCompany.new(:user_id=>curr_user.id,:company_id=>params[:company_id])
@favorite_list.save
render :partial => "create"
end
Any idea what might be wrong? Thanks.
Have you looked at the HTML that is being output via your browsers dev tools (ie firebug, etc)?
I believe you have the
:remote => truein the wrong hash.Try:
Is there a reason you aren’t using Rails Routes and generating the link via the standard Rails process like: