call from view controller method rails -


ba scaffold generated class created :

rails generate scaffold ba src:string descr:string title:string 

i have view home.html.erb there have

<%= render 'layouts/bas' %> 

i made _bas.html.erb file , placed in layouts folder. has code:

  <%  ba.find_each |ba| %> *code* <% end %> 

and works , fine. want place find method in controller cause might bigger find all. in staticpagescontroller created

def bas   @bas = ba.find_each end 

but error bas nill. controller code

  def home   end    def   end   def   end   def contact   end 

you can assign @bas in corresponding controller action , available in view

if need call method on controller view - use helper_method:

helper_method :bas def bas   #code... end 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -