Forum: Ruby on Rails comparing 2 variable

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C306622312e87498aef9b7c04ac596f0?d=identicon&s=25 dhaval (Guest)
on 2007-05-19 14:25
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
15858fbf2415754bf7524e02e5df1469?d=identicon&s=25 adam (Guest)
on 2007-05-19 15:20
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
C306622312e87498aef9b7c04ac596f0?d=identicon&s=25 dhaval (Guest)
on 2007-05-21 07:27
thanks a lot it worked
This topic is locked and can not be replied to.