Hello, I am pretty new to RoR and I am stuck on this problem and not even sure how to troubleshoot it. The issue is that my index.rhtml is not displaying any variables from my controller. Controller (versions_controller.rb) ==================================class VersionController < ApplicationController def index mydate = "20090521" end View (index.rhtml) =================<table> <td> <%= @mydate %> 1 </td></tr> </table> For some reason the view doesn''t see the variable. I also have a def query ... ... ... end in the same controller and it works fine (feeding query.rhtml without any issues). I can even put garbage in the controller such as "a;lskjdfj" and it doesn''t give me a compile error in the controller. Any help would be appreciated. Thanks, Marek -- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser
2009-May-22 13:12 UTC
Re: Stuck on passing variable from controller to view
Marek N. wrote:> Hello, > > I am pretty new to RoR and I am stuck on this problem and not even sure > how to troubleshoot it. The issue is that my index.rhtml is not > displaying any variables from my controller. > > Controller (versions_controller.rb) > ==================================> class VersionController < ApplicationController > def index > mydate = "20090521" > endThat should be @mydate.> > View (index.rhtml) > =================> <table> > <td> > <%= @mydate %> > 1 > </td></tr> > </table>[...]> > Thanks, > > MarekBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Hi, Try this :* @mydate = "20090521" * On Fri, May 22, 2009 at 2:02 PM, Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote:> > Hello, > > I am pretty new to RoR and I am stuck on this problem and not even sure > how to troubleshoot it. The issue is that my index.rhtml is not > displaying any variables from my controller. > > Controller (versions_controller.rb) > ==================================> class VersionController < ApplicationController > def index > mydate = "20090521" > end > > View (index.rhtml) > =================> <table> > <td> > <%= @mydate %> > 1 > </td></tr> > </table> > > For some reason the view doesn''t see the variable. I also have a > def query > ... > ... > ... > end > > in the same controller and it works fine (feeding query.rhtml without > any issues). > > I can even put garbage in the controller such as "a;lskjdfj" and it > doesn''t give me a compile error in the controller. > > Any help would be appreciated. > > Thanks, > > Marek > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rui Carvalho wrote:> Hi, > > Try this : > * > class VersionController < ApplicationController > def index > @mydate = "20090521" > end* > > > > > On Fri, May 22, 2009 at 2:02 PM, Marek N.Hi, thank you both for the quick reply. I did try that - but it still does not pass the value to the view... Is there something outside of the controller and view that could affect this? Thanks, Mark -- Posted via http://www.ruby-forum.com/.
Rui Carvalho wrote:> Hi, > > Try this :* > @mydate = "20090521" > * > > > On Fri, May 22, 2009 at 2:02 PM, Marek N.Hello, Do you mean to add the "@" symbol? I had tried that and numerous other things and it did not work. Also, how could I troubleshoot this? If I could see why the .rhtml is ignoring part of the .rb file, it would help... Thanks, Marek -- Posted via http://www.ruby-forum.com/.
Colin Law
2009-May-22 14:58 UTC
Re: Fwd: Stuck on passing variable from controller to view
To check that the view is interpreting this you could try <%= "value is #{@mydate}" %>. If you see the fixed text then it is just that @mydate is not getting setup for some reason. Possibly a typo that you just can''t get your eye on. What do you mean by "I can even put garbage in the controller such as "a;lskjdfj" and it doesn''t give me a compile error in the controller." Colin 2009/5/22 Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > Rui Carvalho wrote: > > Hi, > > > > Try this :* > > @mydate = "20090521" > > * > > > > > > On Fri, May 22, 2009 at 2:02 PM, Marek N. > > Hello, > > Do you mean to add the "@" symbol? I had tried that and numerous other > things and it did not work. > > Also, how could I troubleshoot this? If I could see why the .rhtml is > ignoring part of the .rb file, it would help... > > Thanks, > Marek > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Colin Law wrote:> To check that the view is interpreting this you could try <%= "value is > #{@mydate}" %>. If you see the fixed text then it is just that @mydate > is > not getting setup for some reason. Possibly a typo that you just can''t > get > your eye on. > > What do you mean by "I can even put garbage in the controller such as > "a;lskjdfj" and it > doesn''t give me a compile error in the controller." > > Colin > > 2009/5/22 Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Hello Colin, That is a good idea for a test case and the fixed text does appear, but not the variable''s value. What kind of typo could cause this? The odd thing is that I have a "def query" below it that is able to pass values to "query.rhtml" without any issues... As for your question, I have two rhtml files, index and query. If I put meaningless junk in "def query" I get the following interpretation error (as expected): undefined local variable or method `laksjdf'' for #<VersionController:0xf6993310> if I copy paste the same junk text into "def index", it does not produce an error (odd right?). This seems to indicate that version_controller.rb is not interpreting the code in "def index" for some reason, but is interpreting it in the "def query" which is directly below it. This is at least consistent with why it is not showing the value for @mydate. I don''t know enough about ruby to figure out what could cause this sort of behaviour. Thanks, Mark -- Posted via http://www.ruby-forum.com/.
Colin Law
2009-May-22 15:27 UTC
Re: Fwd: Stuck on passing variable from controller to view
Post the contents of versions_controller.rb, there must be something wrong there. Strip out some of the unneeded stuff if it is more than a few tens of lines. If you do change it, make sure that it still fails, and that query still works. Colin 2009/5/22 Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > Colin Law wrote: > > To check that the view is interpreting this you could try <%= "value is > > #{@mydate}" %>. If you see the fixed text then it is just that @mydate > > is > > not getting setup for some reason. Possibly a typo that you just can''t > > get > > your eye on. > > > > What do you mean by "I can even put garbage in the controller such as > > "a;lskjdfj" and it > > doesn''t give me a compile error in the controller." > > > > Colin > > > > 2009/5/22 Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > Hello Colin, > > That is a good idea for a test case and the fixed text does appear, but > not the variable''s value. What kind of typo could cause this? The odd > thing is that I have a "def query" below it that is able to pass values > to "query.rhtml" without any issues... > > As for your question, I have two rhtml files, index and query. If I put > meaningless junk in "def query" I get the following interpretation error > (as expected): > > undefined local variable or method `laksjdf'' for > #<VersionController:0xf6993310> > > if I copy paste the same junk text into "def index", it does not produce > an error (odd right?). This seems to indicate that > version_controller.rb is not interpreting the code in "def index" for > some reason, but is interpreting it in the "def query" which is directly > below it. This is at least consistent with why it is not showing the > value for @mydate. I don''t know enough about ruby to figure out what > could cause this sort of behaviour. > > Thanks, > Mark > > > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Colin Law
2009-May-22 15:31 UTC
Re: Fwd: Stuck on passing variable from controller to view
The class should be VersionsController, not VersionController, though that may just be a typo in your post. 2009/5/22 Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>> Post the contents of versions_controller.rb, there must be something wrong > there. Strip out some of the unneeded stuff if it is more than a few tens of > lines. If you do change it, make sure that it still fails, and that query > still works. > > Colin > > 2009/5/22 Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > >> >> Colin Law wrote: >> > To check that the view is interpreting this you could try <%= "value is >> > #{@mydate}" %>. If you see the fixed text then it is just that @mydate >> > is >> > not getting setup for some reason. Possibly a typo that you just can''t >> > get >> > your eye on. >> > >> > What do you mean by "I can even put garbage in the controller such as >> > "a;lskjdfj" and it >> > doesn''t give me a compile error in the controller." >> > >> > Colin >> > >> > 2009/5/22 Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> >> >> Hello Colin, >> >> That is a good idea for a test case and the fixed text does appear, but >> not the variable''s value. What kind of typo could cause this? The odd >> thing is that I have a "def query" below it that is able to pass values >> to "query.rhtml" without any issues... >> >> As for your question, I have two rhtml files, index and query. If I put >> meaningless junk in "def query" I get the following interpretation error >> (as expected): >> >> undefined local variable or method `laksjdf'' for >> #<VersionController:0xf6993310> >> >> if I copy paste the same junk text into "def index", it does not produce >> an error (odd right?). This seems to indicate that >> version_controller.rb is not interpreting the code in "def index" for >> some reason, but is interpreting it in the "def query" which is directly >> below it. This is at least consistent with why it is not showing the >> value for @mydate. I don''t know enough about ruby to figure out what >> could cause this sort of behaviour. >> >> Thanks, >> Mark >> >> >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> >> >> >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Colin Law wrote:> The class should be VersionsController, not VersionController, though > that > may just be a typo in your post. > > 2009/5/22 Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>Yes, that was a typo on my part. The Controller and .rb file are both singular. Thanks, Marek -- Posted via http://www.ruby-forum.com/.
Colin Law
2009-May-22 15:37 UTC
Re: Fwd: Stuck on passing variable from controller to view
They should both be plural, versions_controller.rb and VersionsController class 2009/5/22 Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > Colin Law wrote: > > The class should be VersionsController, not VersionController, though > > that > > may just be a typo in your post. > > > > 2009/5/22 Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > Yes, that was a typo on my part. The Controller and .rb file are both > singular. > > Thanks, > Marek > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Colin Law wrote:> They should both be plural, versions_controller.rb and > VersionsController > class > > 2009/5/22 Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Is this causing the issue? Thanks, Marek -- Posted via http://www.ruby-forum.com/.
Colin Law
2009-May-22 16:04 UTC
Re: Fwd: Stuck on passing variable from controller to view
I don''t know, life will be easier if you stick to the conventions though it may not be the direct cause of the problem The convention would be: table versions model version.rb, class Version controller versions_controller.rb class VersionsController views directory versions Colin 2009/5/22 Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > Colin Law wrote: > > They should both be plural, versions_controller.rb and > > VersionsController > > class > > > > 2009/5/22 Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > Is this causing the issue? > > Thanks, > Marek > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Conrad Taylor
2009-May-22 16:15 UTC
Re: Fwd: Stuck on passing variable from controller to view
On Fri, May 22, 2009 at 9:04 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> I don''t know, life will be easier if you stick to the conventions though it > may not be the direct cause of the problem > > The convention would be: > table versions > model version.rb, class Version > controller versions_controller.rb class VersionsController > views directory versions > > Colin > > > 2009/5/22 Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > >> >> Colin Law wrote: >> > They should both be plural, versions_controller.rb and >> > VersionsController >> > class >> > >> > 2009/5/22 Marek N. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> >> >> Is this causing the issue? >> >> Thanks, >> Marek >> -- >> Posted via http://www.ruby-forum.com/. >> >> >> >In addition to the previous responders to your post, I would recommend reading the following: http://guides.rubyonrails.org/getting_started.html Good luck, -Conrad --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Conrad Taylor wrote:> On Fri, May 22, 2009 at 9:04 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > >> >>> >>> Is this causing the issue? >>> >>> Thanks, >>> Marek >>> -- >>> Posted via http://www.ruby-forum.com/. >>> >>> >>> >> > In addition to the previous responders to your post, I would recommend > reading the following: > > http://guides.rubyonrails.org/getting_started.html > > Good luck, > > -ConradThank you Colin/Conrad, I appreciate your assistance. I am going to read through that doc again (didn''t get everything the first time) and see if I can see what is going on. I''ll post the solution if I find one without starting over and renaming the project. Enjoy the weekend! Best regards, Marek -- Posted via http://www.ruby-forum.com/.