Instance variables added in rails helpers are not available

I am trying to add some instance variables in helpers like the
following:

module ApplicationHelper
def title=(title)
@title = title
end

def title
@title
end
end

and when I assign title in views/pages/index.html.erb like the
following:

<% title = ‘Listing Pages’ %>

and try to show it in the views/layouts/application.html.erb like the
following:

<%= title %>

it is showing as ‘’ and after some debugging, looks like @title is not
being set.

Why are the instance variables added in the helpers not available in the
views (templates)?

Thanks in advance.

On Aug 28, 3:11 pm, Saty N. [email protected] wrote:

<%= title %>

it is showing as ‘’ and after some debugging, looks like @title is not
being set.

Why are the instance variables added in the helpers not available in the
views (templates)?

because you didn;t create an instance variable. you just created a
local variable called title (your title= method was never called)

Fred

Frederick C. wrote:

On Aug 28, 3:11�pm, Saty N. [email protected] wrote:

<%= title %>

it is showing as ‘’ and after some debugging, looks like @title is not
being set.

Why are the instance variables added in the helpers not available in the
views (templates)?

because you didn;t create an instance variable. you just created a
local variable called title (your title= method was never called)

Fred

thanks fred, using self.title = ‘some title’ solved the problem