Hi Philip,
Sorry, I was actually asking two different questions in my last reply.
You've answered my question about the console, thanks for your help!
It's much clearer now.
I've put the " include 'amatch' " in both my Post model and my Response
model, which have a one to many relationship. However, I get this error
message:
NameError in Posts#show
Showing app/views/posts/show.html.erb where line #8 raised:
uninitialized constant Response::Amatch
here's my code for the post model:
class Post < ActiveRecord::Base
include Amatch
has_many :responses
validates_presence_of :title
validates_length_of :title, :within => 3..10
end
and the Response model:
class Response < ActiveRecord::Base
include Amatch
belongs_to :post
validates_uniqueness_of :title
validates_presence_of :title
validates_length_of :title, :within => 3..5
validate :title_must_have_changed_by_one_letter
protected
def title_must_have_changed_by_one_letter
m = Amatch::Sellers.new(title)
errors.add_to_base("Sorry, you must change the last submitted string
by one letter") if m.match(self.response.last) != 1.0
end
end
Would I need to include Amatch in the controller and views as well?
Phillip Ridlen wrote:
> If I'm understanding you correctly, you want to load up script/console
> (or
> rails console), instantiate a Seller object, and then access it from the
> browser? I'm not sure you can do that, because your console is a
> separate
> instance of the application (it may access the same database but it's
> running in a different location in memory if I understand it correctly).
>
> If you're just trying to get it to work in your application (no
> console),
> then where are you putting `require 'amatch'`? Somewhere all of the
> parts of
> your app need it, I hope!
>
> Phillip Ridlen
> @philtr
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.