Topic: Undefined Method...

Please be patient... I'm not even sure I know enough about what I'm doing to explain the problem. I've never really done anything in Rails before.

I'm trying to develop a simple little changelog/todo list tracking application as a way to dive into rails and start learning. So, I've set up my databases and my rails app, created models and controler for my "projects" table. Everything works great, so I went back to add a little error handling in app/models/project.rb

class Project < ActiveRecord::Base
        validates_uniqueness_of :project, :message => "This project already exists."
end

Seems simple enough, right? Only the problem is that now, whenever I try to create a new project, I get the following:

NoMethodError in Project#create
undefined method `project' for #<Project:0x405e72f8>

Validates_length_of didn't work, either, so I'm thinking that nothing I put in there's going to work and I have no clue why. If I take the validation check out, I can insert records all day long using the raisld efaults.

Keep in mind that all I've done so far is:
- initial rails app setup
- create database & tables
- provide database info in database.yml
- generated "project" model for "projects" database
- generated "project" controller for "projects" database
- added the scaffold to the controller

Any thoughts, ideas, suggestions? Feel free to toss rotten tomatos at me if I'm doing something stupid. Thanks. smile

(Can you tell I'm not an admin because of my MadRubySkillz?)

Re: Undefined Method...

What is your database structure for this object?

I suspect you need something like :name or similar instead of :project

Last edited by NielsenE (2006-06-18 15:36:23)

My RoR journey  -- thoughts on learning RoR and lessons learned in applying TDD and agile practices.

Re: Undefined Method...

Gyah. I am an idiiot. You're right. I should have been checking :title. Thanks so much. smile

Re: Undefined Method...

Holy crap.  Kelli Shaver is getting into Rails development.  Kelli, you have some of the best design skills I've ever seen, you'll be unstoppable if you also develop Rails apps.

I hope you take it as a compliment that I'm totally afraid of your abilities :-)

Re: Undefined Method...

*BLUSH!*

Why thank you, sir! smile

Rails Day inspired me to finally stop complaining about the differences and just learn the language/framework. I've tried in the past, but couldn't really get into it. It's making a lot more sense to me now, though, for some reason. This is probably because I've spent the better part of the last year just learning object-oriented programming principles in general, as I worked through them in PHP.