jborup | 9 Jul 01:02

undefined method `name' ...........


Hi Community....

I'm new in this game, so this might be a easy question, but I have
done my google, without result, so I will try this....

I'm learning ROR, and I'm using Patrick Lens 'Ruby on Rails'  book.
(This is written for ror 1.x - and I'm using NetBeans 6.1 - ror 2.x -
this might  be the problem...)

But...

I have made this Controller:

class StoryController < ApplicationController
  def index
    @current_time = Time.now
    @s = Story.find_all_by_name('sitepoint')
  end
end

and this view:

<h1>Story#index</h1>
hej
<%= @current_time %>
<%= @s.name%>
<p>Find me in app/views/story/index.html.erb</p>

And, when browsing my 'story' (http://localhost:3000/story), I get
(Continue reading)

Rimantas Liubertas | 9 Jul 01:13

Re: undefined method `name' ...........


> I have made this Controller:
>
> class StoryController < ApplicationController
>  def index
>    @current_time = Time.now
>    @s = Story.find_all_by_name('sitepoint')
>  end
> end
<...>

> Now using the Rails console within Netbeans, gives me this
>>> v = Story.find_by_name('sitepoint')
> v = Story.find_by_name('sitepoint')
> => #<Story id: 2, name: "sitepoint", link: "http://sitepoint">
>>> v.name
> v.name
> => "sitepoint"
>
> No problem with 'name' - so what is the difference ? -

Can you spot a difference between
  Story.find_all_by_name('sitepoint')
and
Story.find_by_name('sitepoint') ?

Now think, what you get back from the first query, and what you get
back from the second one.
Then answer yourself, does Array have an 'name' attribute?

(Continue reading)

Philip Hallstrom | 9 Jul 01:14

Re: undefined method `name' ...........


On Jul 8, 2008, at 4:03 PM, jborup wrote:

>
> Hi Community....
>
> I'm new in this game, so this might be a easy question, but I have
> done my google, without result, so I will try this....
>
> I'm learning ROR, and I'm using Patrick Lens 'Ruby on Rails'  book.
> (This is written for ror 1.x - and I'm using NetBeans 6.1 - ror 2.x -
> this might  be the problem...)
>
> But...
>
> I have made this Controller:
>
> class StoryController < ApplicationController
>  def index
>    @current_time = Time.now
>    @s = Story.find_all_by_name('sitepoint')
>  end
> end
>
> and this view:
>
> <h1>Story#index</h1>
> hej
> <%= @current_time %>
> <%= @s.name%>
(Continue reading)

jborup | 9 Jul 01:38

Re: undefined method `name' ...........


Yes.... hmmm.... that is very clear, and removing the all, solved the
problem.... guess it is getting a bit late....

Thank you for you comments... I'm back on track.....

Regards Jørn.

On Jul 9, 1:14 am, Philip Hallstrom <phi...@...> wrote:
> On Jul 8, 2008, at 4:03 PM, jborup wrote:
>
>
>
>
>
> > Hi Community....
>
> > I'm new in this game, so this might be a easy question, but I have
> > done my google, without result, so I will try this....
>
> > I'm learning ROR, and I'm using Patrick Lens 'Ruby on Rails'  book.
> > (This is written for ror 1.x - and I'm using NetBeans 6.1 - ror 2.x -
> > this might  be the problem...)
>
> > But...
>
> > I have made this Controller:
>
> > class StoryController < ApplicationController
> >  def index
(Continue reading)


Gmane