Rails problem

I'm a Java programmer and am new to Rails and Ruby so be gentle.

I'm not sure this is the appropriate group for this question. I'm sure
you'll let me know if it isn't.

I've a Rails app that uses a "Tickets" table. I used the scaffold to
generate the controller.

I can show a list of rows in the table with the "list" URL and I can
"Show" any one of the records in the result as expected. But when I
try to "Edit" any one of the records I get this error in the browser:

···

---------------------------------------------------------------

NoMethodError in Tickets#edit

Showing /tickets/_form.rhtml where line #7 raised:

undefined method `store' for #<Ticket:0x23b36f4>

Extracted source (around line #7):

4:
5: <!--[form:ticket]-->
6: <p><label for="ticket_store">Store</label><br/>
7: <%= text_field 'ticket', 'store' %></p>
8:
9: <p><label for="ticket_order_id">Order</label><br/>
10: <%= text_field 'ticket', 'order_id' %></p>

--------------------------------------------------------------

One of the fields of the table is "store". So I figure there is a
"store" method somewhere that should return the value of the store
field for the "current" row. Also I figure that this is the way that
the "Show" works (and it seems to work fine).

How can I debug this? Where is the "store" method supposed to be?
I've searched the app and it doesn't appear in any of the .rb files.

Rick asked:

I'm not sure this is the appropriate group for this question. I'm sure
you'll let me know if it isn't.

It isn't. The Rails mailing list is.

http://lists.rubyonrails.org/mailman/listinfo

But we can still answer some of these questions here.

I've a Rails app that uses a "Tickets" table. I used the scaffold to
generate the controller.

I can show a list of rows in the table with the "list" URL and I can
"Show" any one of the records in the result as expected. But when I
try to "Edit" any one of the records I get this error in the browser:

---------------------------------------------------------------

NoMethodError in Tickets#edit

Showing /tickets/_form.rhtml where line #7 raised:

undefined method `store' for #<Ticket:0x23b36f4>

Extracted source (around line #7):

4:
5: <!--[form:ticket]-->
6: <p><label for="ticket_store">Store</label><br/>
7: <%= text_field 'ticket', 'store' %></p>
8:
9: <p><label for="ticket_order_id">Order</label><br/>
10: <%= text_field 'ticket', 'order_id' %></p>

--------------------------------------------------------------

One of the fields of the table is "store". So I figure there is a
"store" method somewhere that should return the value of the store
field for the "current" row. Also I figure that this is the way that
the "Show" works (and it seems to work fine).

How can I debug this? Where is the "store" method supposed to be?
I've searched the app and it doesn't appear in any of the .rb files.

Your code says:
  text_field 'ticket', 'store'

That means you want a text field based on the column "store" in your Ticket
model. So you should have app/models/ticket.rb with a Ticket class. If your
database is configured OK, then ActiveRecord will automatically give Ticket
a store method for the store column on the database. If your database isn't
connecting, that could cause an error like this.

Cheers,
Dave

Thanks, I found the list after this post.

The connection is ok because I can list records and show a record. The
error above only occurs when displaying the edit form.

I've only two lines in my Ticket class:

class Ticket < ActiveRecord::Base
    set_table_name "master"
    set_primary_key "sequence"
end

I'm wondering if it could be something related to setting a different
table name.

Maybe it's a problem with ActiveRecord and not Rails.

Please, don't.

Instead, CC the original recipient and post your response to the rails mailing list.

···

On Oct 24, 2005, at 8:37 AM, Dave Burt wrote:

Rick asked:

I'm not sure this is the appropriate group for this question. I'm sure
you'll let me know if it isn't.

It isn't. The Rails mailing list is.

http://lists.rubyonrails.org/mailman/listinfo

But we can still answer some of these questions here.

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

Why do you say this?

It seems on topic here too. If we ruled out talking about the things built with Ruby, what ever would we talk about? :wink:

James Edward Gray II

···

On Oct 24, 2005, at 3:52 PM, Eric Hodel wrote:

On Oct 24, 2005, at 8:37 AM, Dave Burt wrote:

Rick asked:

I'm not sure this is the appropriate group for this question. I'm sure
you'll let me know if it isn't.

It isn't. The Rails mailing list is.

http://lists.rubyonrails.org/mailman/listinfo

But we can still answer some of these questions here.

Please, don't.

Instead, CC the original recipient and post your response to the rails mailing list.

James Edward Gray II wrote:

Rick asked:

I'm not sure this is the appropriate group for this question. I'm sure
you'll let me know if it isn't.

It isn't. The Rails mailing list is.

http://lists.rubyonrails.org/mailman/listinfo

But we can still answer some of these questions here.

Please, don't.

Instead, CC the original recipient and post your response to the rails mailing list.

Why do you say this?

It seems on topic here too. If we ruled out talking about the things built with Ruby, what ever would we talk about? :wink:

There are some topics that tend to focus on the quirks and specifics of some particular tool or library rather than Ruby coding in general, and if there is an existing list devoted to that tool or library then that becomes the more appropriate place for such topics.

The answer to this question may be of little value to any Rubyist who isn't using Rails, while those people with a specific interest in Rails might not ever see it, because they only read the Rails list.

And Rails (or Nitro or Wee or IOWA or ...) -specific questions are more likely to get a faster, more accurate response on a dedicated list.

James

···

On Oct 24, 2005, at 3:52 PM, Eric Hodel wrote:

On Oct 24, 2005, at 8:37 AM, Dave Burt wrote:

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys