I believe that You cannot call a controller model from another
controller in this way. If you need to do this it probably means that
the method should be in a model or in a module in the lib directory.
Or are you actually trying to redirect to a different action rather
than just call a method?
Sorry I misread the question and the reply above is rubbish anyway. I
thought you were wanting to call a controller method from another
controller. I must remember to engage brain before typing.
Colin
hi Colin
That is not a problem
You have the mind to help that is far more enough even if you misjudged
def check1
in model1.rb my line to access check2 method is
model2.check2
I believe that You cannot call a controller model from another
controller in this way. Â If you need to do this it probably means that
the method should be in a model or in a module in the lib directory.
Or are you actually trying to redirect to a different action rather
than just call a method?
Sorry I misread the question and the reply above is rubbish anyway. I
thought you were wanting to call a controller method from another
controller. I must remember to engage brain before typing.
On Mon, Aug 31, 2009 at 3:38 PM, karthik k [email protected] wrote:
This is anew Question
i am writing a method in model
In check1.rb //model
def check?
self.name=“karthik”
I think that should be self.name == “Karthik”
Please guide me how to do
def check?( a_name )
self.name == a_name
end
Then check1.check?( “karthik” )
If you call it immediately after check1.new then the name will always
be the default one for the name attribute of course. check1.check?(
“karthik” ) means hey object check1, is your name karthik?
In check1.rb //model
i am calling as
self.name == a_name
end
Then check1.check?( “karthik” )
If you call it immediately after check1.new then the name will always
be the default one for the name attribute of course. check1.check?(
“karthik” ) means hey object check1, is your name karthik?
There are a lot of mistakes (bug) in your code, but I think
philosophically
too you are wrong.
Firstly, you have “=” instead of “==” in your check? method. And if the
word
“karthik” is constant you don’t need to pass it. I think this solves
your
problem.
But please do read some detailed tutorial or preferably a book on rails,
because I think you are missing too many points here.
so that it will return true or false
If you call it immediately after check1.new then the name will always
I think we are loosing something in the translation in this conversation.
Colin
Hi
Same old model problem
role.rd //model
def check_role
puts “Role sdfsdfd”
end
presenter.rb //model
def validate_name
self.role.check_role //calling from role.rb model
end
answer.
Karthik, I have a two suggestions which I would like you consider very
This may seem like a lot of wasted time but in the long run it will
save you (and us) time and effort and will allow you develop reliable
applications much more effectively than you can at the moment.
I am not able to under stand
Does Presenter have a role method ?
no there is no method in Presenter model
can you plz explain in detail
Karthik, I have a two suggestions which I would like you consider very
seriously.
Get hold of the Pragmatic Bookshelf book Programming Ruby: The
Pragmatic Programmer’s Guide, downloadable as an e-book. Spend a week
working through it till you have a good grasp of Ruby.
Get the book Agile Web D. with Rails, 3rd Edition and
spend another week (or more) working through that to give you a good
grasp of Rails.
This may seem like a lot of wasted time but in the long run it will
save you (and us) time and effort and will allow you develop reliable
applications much more effectively than you can at the moment.
Colin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.