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 -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -