Undefined method `generated_methods'

i m getting this error…

undefined method `generated_methods’ for “chop”:String

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/attribute_methods.rb:188:in
`method_missing’

app/controllers/chops_controller.rb:60:in `show’


here is the function show
def show
@chop = Chop.find(params[:id], :include => [:song])

#bump up the views up
@chop.views = @chop.views.next
@chop.save
@page_title = @chop.song.name + " by " + @chop.artist.name

@series = Chop.find(:all, :conditions => " artist_id =
#{@chop.artist_id} AND id != #{@chop.id} AND song_id = #{@chop.song_id}
AND instrument_id = #{@chop.instrument_id}", :limit => 10)

@others = Chop.find(:all, :conditions => " artist_id =
#{@chop.artist_id} AND id != #{@chop.id} AND song_id != #{@chop.song_id}
AND instrument_id = #{@chop.instrument_id}", :limit => 10)

get amazon products

@query = @chop.artist.name #amazon query
#amazon_search
end

Manish N. wrote:

app/controllers/chops_controller.rb:60:in `show’


here is the function show
def show
:
end

Which is line 60 (where the error is)?

What are the params passed into the action when it fails (shown in your
log file)? What happens when you run this line (below) from the
application console?

@chop = Chop.find(params[:id], :include => [:song])

line 60 is ------->
@chop.views = @chop.views.next

Manish N. wrote:

line 60 is ------->
@chop.views = @chop.views.next

What params were passed in when you get the error? In particular,
params[:id]?

In the application console, run this replacing “params[:id]” with the
appropriate value from above:

@chop = Chop.find(params[:id], :include => [:song])

What does it display?
What is the value of @chop.views?
What is the value of @chop.views.next?

Is “views” an association in the Chop model? If so, what is the related
model? If not what is the database type? Are there any relevant
setters/getters for the Chop model.

Manish N. wrote:

In params[:id] = 567 is passed. 567 is the id of music in table.

I am new to ROR so i dont know how to run application console. so please
guide me.

Ah. Then you are in for a pleasant surprise. :slight_smile:

The application console is one of the most amazingly useful parts of
Rails. To access it, you need a command window (a terminal on
UNIX/MacOS or a DOS window on Windows). If you are using Instant Rails
on Windows, then select “Open Ruby Console Window” from the “Rails
Applications” menu option.

Change directory so you are in the top level of your application. Then
run the command:

ruby script/console

If you are running an older dumb(er) version of Windows it may want you
to use backslash instead of forward slash there (script\console).

This will load your development application and allow you to interact
with it. It is like running “irb” (the interactive Ruby environment)
with your Rails application already loaded.

You can then run any command which accesses your models. For example,
you can run:

@chop = Chop.find(567, :include => [:song])

and it will extract this item from the database. After each command is
run, the value of the command is displayed. If you just enter a
variable name, it will display its value, etc.

There’s a lot more you can do, too, as you have access to the routing
engine to see how URLs are mapped, etc and much more, but to start with
it is very useful to play with your models and see how they are working.
Any database access will be logged in your log file.

Use “quit” (or Ctrl-D) to exit.

Your error message indicates that at some point you have the String
“chop” which Rails is trying to generate methods for. If you enter the
following at the console:

@chop.views
@chop.views.next

you will see what Rails is trying to do when executing the line:

@chop.views = @chop.views.next

It should give you some good clues to the actual problem.

In params[:id] = 567 is passed. 567 is the id of music in table.

I am new to ROR so i dont know how to run application console. so please
guide me.

Manish N. wrote:

and when i [email protected] = @chop.views.next
NoMethodError: undefined method ‘columns_hash’ for “chop”

For some reason, you have a string (“chop”) where Rails is expecting you
to have a model by the look of it.

After you get the value from:

@chop = Chop.find(567, :include => [:song])

what is the value of @chop and @chop.views? Can you post these 2 values
and it might be clearer what is happening?

Mark B. wrote:

Manish N. wrote:

and when i [email protected]d = @chop.views.next
NoMethodError: undefined method ‘columns_hash’ for “chop”

For some reason, you have a string (“chop”) where Rails is expecting you
to have a model by the look of it.

After you get the value from:

@chop = Chop.find(567, :include => [:song])

what is the value of @chop and @chop.views? Can you post these 2 values
and it might be clearer what is happening?

When i write
@chop …i get the value—>nil
@chop.views… i get the error---->NoMethodError: You have the nil
object when you didn’t expect it! The error occured while evaluating
nil.views from (irb):1

tht its…

but when i run @chop = Chop.find(567, :include => [:song])

i get whole value from database. its very big so i cannt paste here.

Thx Bush for u r tips…
its were really amazing and new for me.

many many many thx 1st of all.

Now
when i run —@chop = Chop.find(567, :include => [:song])
i got all the data from the database realted with it.

and when i [email protected] = @chop.views.next
NoMethodError: undefined method ‘columns_hash’ for “chop”

this type of error i m getting…

Manish N. wrote:

@chop.views… i get the error---->NoMethodError: You have the nil

What is this value (of @chop.views) immediately after running:

@chop = Chop.find(567, :include => [:song])

That is, what is the value of the “views” attribute of this particular
Chop object?

On 20 Mar 2008, at 16:02, Mark B. wrote:

Chop object?
While we’re at it, what is views? An attribute, an association, a
method computing some value ?

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs