I am very new to ruby on rails, but simple operation is driving me crazy
I am passing variables from Controller to View
But it’s nil in the view I read all the questions similar to mine but none of them was the solution
I have a method called news_read
def news_read
@name = "Come On "
end
And in the right associated view (news_read.html.erb) I try this
<%= @name.inspect %>
But the value on the browser is
nil
I am having trouble with 3 hours ago and it’s not working at all
Any help will be appreciated
Edit
I tried to log something but it has not being invoked so my routes look something like this
get "main/news_read"
get "main/index"
root :to => 'main#index', :as => 'main'
resources :categories
resources :testimonials
resources :news
resources :products
resources :teams
resources :abouts
resources :main
resources :header_titles
I fixed that I was trying to specify another layout according to action name and that method was private I don’t know why it prevent it but removing it fixed the problem
It was like this
The solution is this