Comparing 2 variable


#1

hello

I want to compare 2 variables the variables gets the data from the
database

<% for subnew in @subnews %>

<% if( @news_id == subnew[“news_id”]) %>
.
.
.
.
.
action
.
.
.
.
end

the news_id is getting the value from the controller but when comparing
in rails they want <%= news_id == subnew[“news_id”]) %> where as i want
to make it in @news_id but its not working

please suggest me some new method for it

thanks


#2

try <% if( @news.id.to_s == subnew[“news_id”].to_s) %>

dhaval wrote:

hello

I want to compare 2 variables the variables gets the data from the
database

the news_id is getting the value from the controller but when comparing
in rails they want <%= news_id == subnew[“news_id”]) %> where as i want
to make it in @news_id but its not working

please suggest me some new method for it

thanks


#3

thanks a lot it worked