Stuck on passing variable from controller to view

Hi,

Try this :

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

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

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

The class should be VersionsController, not VersionController, though that may just be a typo in your post.

Colin Law wrote:

The class should be VersionsController, not VersionController, though that may just be a typo in your post.

Yes, that was a typo on my part. The Controller and .rb file are both singular.

Thanks, Marek

They should both be plural, versions_controller.rb and VersionsController class

Colin Law wrote:

They should both be plural, versions_controller.rb and VersionsController class

Is this causing the issue?

Thanks, Marek

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

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

Conrad Taylor wrote: