Using @variable within link_to in Rails -


i'm trying make

<%= link_to @company.name, current_company %> 

work. work, long stay within same profile page. i'm trying leave it, nomethoderror in staticpages#about - undefined method `name' nil:nilclass. understand problem lies within controller (i guess?), that's it. can point me in right direction please.

updated

updating methods in satic_pages controller to

  def home     @company = company.new   end    def     @company = company.new   end 

helps skipping error, instead of company name links start

/companies/2 

update: since want link display company name, can <%= link_to @company.name, @company%>

in controller, want reference company you're linking to, can @company = company.last. take last record created. now, when load page, link should take show page company last company's name text hyperlink.


Comments