[Rails] Re: wrong number of arguments (3 for 2)

2012-08-01 Thread deal bitte
yaa...but this line throws no error

 config.nested.add_link(:procedureexecutions, :label = Run, :inline 
= false)


Colin Law wrote in post #1070901:
 On 1 August 2012 12:02, deal bitte li...@ruby-forum.com wrote:
 wrong number of arguments (3 for 2) I am getting this error for the
 following lines. I have moved to Rails 3.2.6 and am facing this problem
 here. It worked in Rails 2.3.5


 config.nested.add_link( 'Procs', [:historical_testprocedures], :action
 = 'editprocedures', :controller = 'Testruns' )

 Look at the docs for add_link and you will see it only takes two
 params, the second of which is the options, so you have too many
 parameters as the error says.

 Colin

-- 
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: wrong number of arguments (3 for 2)

2012-08-01 Thread Gintautas Šimkus
That's two params: Symbol (:procedureexecutions), followed by a hash (which
omits {}): :label = Run, :inline
= false )

So that's fine.

2012/8/1 deal bitte li...@ruby-forum.com

 yaa...but this line throws no error

  config.nested.add_link(:procedureexecutions, :label = Run, :inline
 = false)


 Colin Law wrote in post #1070901:
  On 1 August 2012 12:02, deal bitte li...@ruby-forum.com wrote:
  wrong number of arguments (3 for 2) I am getting this error for the
  following lines. I have moved to Rails 3.2.6 and am facing this problem
  here. It worked in Rails 2.3.5
 
 
  config.nested.add_link( 'Procs', [:historical_testprocedures], :action
  = 'editprocedures', :controller = 'Testruns' )
 
  Look at the docs for add_link and you will see it only takes two
  params, the second of which is the options, so you have too many
  parameters as the error says.
 
  Colin

 --
 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 rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.





-- 
Pagarbiai,
Gintautas

-- 
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: wrong number of arguments (2 for 0..1)

2011-08-09 Thread praveen k.
Kurtis Rainbolt-greene wrote in post #1015633:
 Try this:

 https://gist.github.com/1133491


 On Mon, Aug 8, 2011 at 10:36 PM, praveen k. li...@ruby-forum.com
 wrote:
 wrong number of arguments (2 for 0..1)
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.





 --
 Kurtis Rainbolt-Greene:
 - Hacker, Designer, Author
 - 3725 Onyx Street, Eugene, OR 97405
 - (202) 643-2263

thankyou Kurtis Rainbolt-Greene. ya i tried it but even it is giving me
an error.
error:
undefined method `condition' for Bird(id: integer, state: string, city:
string):Class
Thankyou

-- 
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: wrong number of arguments error

2010-11-29 Thread Marnen Laibow-Koser
John Merlino wrote in post #964838:
 Hey all,

 I did a script/generate controler users in console.

 Then I added the following to users controller:

 class UsersController  ApplicationController
   def initialize(first_name, last_name)
 @first_name = first_name
 @last_name = last_name
   end

   def full_name()

You don't need the empty parentheses.

 return #...@first_name} + #...@last_name}
   end
 end


No!  These methods belong in the model, not the controller.  Review MVC 
philosophy: a model object represents data.  The controller mediates 
between the model and the view.

 I have this in users/index.html.erb

 % user = UsersController.new(John, Merlino) %

Again, you want User, not UsersController.


 h1%= puts(user.full_name()) %/h1

 and in routes:
   map.root :controller = 'users'

 I get error:
 ArgumentError in UsersController#index

 wrong number of arguments (0 for 2)

 Thanks for response.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: wrong number of arguments error

2010-11-29 Thread John Merlino
You are right. It worked. Nevertheless, the behavior was the same. We 
instantiated an object and called a constructor method of the class. 
Both User and UsersController are classes. I don't know what is causing 
the behavior to be different. Are there any good books on MVC design 
patterns? I already have the book Design Patterns in Ruby and I don't 
see MVC mentioned in it. Thanks for response.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: wrong number of arguments error

2010-11-29 Thread Frederick Cheung


On Nov 29, 7:34 pm, John Merlino li...@ruby-forum.com wrote:
 You are right. It worked. Nevertheless, the behavior was the same. We
 instantiated an object and called a constructor method of the class.
 Both User and UsersController are classes. I don't know what is causing
 the behavior to be different.

Rails creates an instance of your controller for you as part of the
request handling process, and is probably expecting a controllers
initialize method to take 0 arguments, but since you've changed the
signature of initialize that blows up. Overriding initialize like that
on a subclass of ActiveRecord will also cause trouble but it might
take a little longer for you to get into trouble.

Fred
Are there any good books on MVC design
 patterns? I already have the book Design Patterns in Ruby and I don't
 see MVC mentioned in it. Thanks for response.

 --
 Posted viahttp://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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: wrong number of arguments error

2010-11-29 Thread Marnen Laibow-Koser
John Merlino wrote in post #964846:
 You are right. It worked. Nevertheless, the behavior was the same. We
 instantiated an object and called a constructor method of the class.
 Both User and UsersController are classes. I don't know what is causing
 the behavior to be different.

Gee, do you think it could have something to do with the fact that they 
inherit from different parents -- which could change the behavior?

 Are there any good books on MVC design
 patterns? I already have the book Design Patterns in Ruby and I don't
 see MVC mentioned in it. Thanks for response.

Any basic Rails reference (including the Guides) explains how Rails uses 
MVC.  You probably don't need Design Patterns in Ruby for *anything* at 
this stage...

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Wrong number of arguments (0 for 1) in callback method

2009-11-15 Thread Kalpesh Patel

Hi Matt,
Actually I am trying to connect to already existing DB where mentioned
table is readily available. I just need to read it all the time or
occasionally write it but I do not create it from my app. The primary
key of the table is varchar. I can do nothing about that and if i do
not declare it into my model, it will assume a primary key 'id' in the
table. Is there any better way here?

PS: i cannot see your posting on ruby-forum. Will it take LOTS of time
for that to appear on the site or something else?

-Kalpesh

On Sat, Nov 14, 2009 at 10:54 PM, Matt Jones al2o...@gmail.com wrote:

 Somewhat unrelated, but if you're creating a new, simple Rails app,
 why are you tangling with set_table_name and a noninteger primary key?
 Working against the Rails conventions will cause no end of trouble,
 especially if you're just starting out...

 --Matt Jones

 On Nov 13, 4:00 am, Kalpesh1 Patel rails-mailing-l...@andreas-s.net
 wrote:
 I was creating this simple rail application. my controller method looks
 like this:
 ---
 def create()
 @simple = Simple.new(params[:simple]) ##params coming from view
 @simple.save
 end
 ---

 And my model class Simple as below:

 ---
 class Simple  ActiveRecord::Base
   set_table_name name_desc_table
   set_primary_key name

   before_create :init_name

   private
   def init_name(cname)
 self.name = cname
   end
 end
 ---

 When I run this in browser, it throws error Wrong number of arguments
 (0 for 1). Obviously, my method init_name expects one parameter and
 it doesn't find any while called(by controller??). Basically I want to
 send this 'cname' variable from controller to model. Can anybody tell me
 what can I do in controller method so that 'cname' variable is passed
 when callback method is called?

 Thanks,
 -Kalpesh
 --
 Posted viahttp://www.ruby-forum.com/.
 




-- 
Why so serious?

--~--~-~--~~~---~--~~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments (0 for 1) in callback method

2009-11-14 Thread Matt Jones

Somewhat unrelated, but if you're creating a new, simple Rails app,
why are you tangling with set_table_name and a noninteger primary key?
Working against the Rails conventions will cause no end of trouble,
especially if you're just starting out...

--Matt Jones

On Nov 13, 4:00 am, Kalpesh1 Patel rails-mailing-l...@andreas-s.net
wrote:
 I was creating this simple rail application. my controller method looks
 like this:
 ---
 def create()
     @simple = Simple.new(params[:simple]) ##params coming from view
     @simple.save
 end
 ---

 And my model class Simple as below:

 ---
 class Simple  ActiveRecord::Base
   set_table_name name_desc_table
   set_primary_key name

   before_create :init_name

   private
   def init_name(cname)
     self.name = cname
   end
 end
 ---

 When I run this in browser, it throws error Wrong number of arguments
 (0 for 1). Obviously, my method init_name expects one parameter and
 it doesn't find any while called(by controller??). Basically I want to
 send this 'cname' variable from controller to model. Can anybody tell me
 what can I do in controller method so that 'cname' variable is passed
 when callback method is called?

 Thanks,
 -Kalpesh
 --
 Posted viahttp://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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments (0 for 1) in callback method

2009-11-13 Thread Frederick Cheung



On Nov 13, 9:00 am, Kalpesh1 Patel rails-mailing-l...@andreas-s.net
wrote:

 When I run this in browser, it throws error Wrong number of arguments
 (0 for 1). Obviously, my method init_name expects one parameter and
 it doesn't find any while called(by controller??). Basically I want to
 send this 'cname' variable from controller to model. Can anybody tell me
 what can I do in controller method so that 'cname' variable is passed
 when callback method is called?

Callbacks like before_create can't take any arguments

Fred

 Thanks,
 -Kalpesh
 --
 Posted viahttp://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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments (0 for 1) in callback method

2009-11-13 Thread Kalpesh1 Patel

Frederick Cheung wrote:
 On Nov 13, 9:00�am, Kalpesh1 Patel rails-mailing-l...@andreas-s.net
 wrote:
 
 When I run this in browser, it throws error Wrong number of arguments
 (0 for 1). Obviously, my method init_name expects one parameter and
 it doesn't find any while called(by controller??). Basically I want to
 send this 'cname' variable from controller to model. Can anybody tell me
 what can I do in controller method so that 'cname' variable is passed
 when callback method is called?
 
 Callbacks like before_create can't take any arguments
 
 Fred

So isn't there any way I can pass some value from controller to model?
-- 
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments (0 for 1) in callback method

2009-11-13 Thread Leonardo Mateo

On Fri, Nov 13, 2009 at 10:39 AM, Kalpesh1 Patel
rails-mailing-l...@andreas-s.net wrote:

 Frederick Cheung wrote:
 On Nov 13, 9:00�am, Kalpesh1 Patel rails-mailing-l...@andreas-s.net
 wrote:

 When I run this in browser, it throws error Wrong number of arguments
 (0 for 1). Obviously, my method init_name expects one parameter and
 it doesn't find any while called(by controller??). Basically I want to
 send this 'cname' variable from controller to model. Can anybody tell me
 what can I do in controller method so that 'cname' variable is passed
 when callback method is called?

 Callbacks like before_create can't take any arguments

 Fred

 So isn't there any way I can pass some value from controller to model?
What do you mean? Of course you can pass values, in fact, you're
passing a value there.
I don't see the need of doing something like the before_create hook.
Why don't you just pass the value to the constructor? Simple.new(:name
= params[:simple])


-- 
Leonardo Mateo.
There's no place like ~

--~--~-~--~~~---~--~~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments (0 for 1) in callback method

2009-11-13 Thread Sijo k g

Hi Kalpesh1 Patel

 So isn't there any way I can pass some value from controller to model?

You can define cname as n attr_writer in model and can set its value 
from controller like @simple.cname = 'namehere'


Sijo

-- 
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments (0 for 1) in callback method

2009-11-13 Thread Kalpesh1 Patel

Sijo k g wrote:
 Hi Kalpesh1 Patel
 
 So isn't there any way I can pass some value from controller to model?
 
 You can define cname as n attr_writer in model and can set its value 
 from controller like @simple.cname = 'namehere'
 
 
 Sijo

Thanks sijo! I am able to get/set it using attr_accessor now :)
-- 
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments (0 for 1) in callback method

2009-11-13 Thread Kalpesh1 Patel

Leonardo Mateo wrote:
 On Fri, Nov 13, 2009 at 10:39 AM, Kalpesh1 Patel
 rails-mailing-l...@andreas-s.net wrote:
 when callback method is called?

 Callbacks like before_create can't take any arguments

 Fred

 So isn't there any way I can pass some value from controller to model?
 What do you mean? Of course you can pass values, in fact, you're
 passing a value there.
 I don't see the need of doing something like the before_create hook.
 Why don't you just pass the value to the constructor? Simple.new(:name
 = params[:simple])
 
 
 --
 Leonardo Mateo.
 There's no place like ~

I need before_create because I want to do some preprocessing everytime i 
save my 'Simple' state in the DB. For example, authentication, logging 
or similar stuff I will perform just before 'save'(this might raise 
another question, is this right approach? but this can be a separate 
discussion). I thought of passing the value in the callback method 
itself but now I am able to do it through attr_accessor. Thanks Leo for 
the suggestion :)

-Kalpesh
-- 
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments (0 for 1)

2009-09-16 Thread Frederick Cheung



On Sep 16, 8:05 pm, RubyonRails_newbie craigwest...@googlemail.com
wrote:
 Hi everyone,

 I am running through the RailsSpace tutorial. I'm trying to figure out
 the advanced login section, which in short creates a cookie and an
 authorization token in the users table in the database.

 My trouble is, I'm getting error: Wrong number of arguments (0 for 1)

 the code that has been updated is as follows:

 In ApplicationController:

 before_filter :check_authorization


What does you check_authorization method look like  ? What's the
backtrace when you get that error ?

Fred
 When I comment this line out, the application is displayed without
 error. Unfortunately i don't know enough about rails to understand how
 to fix this. However without it, I can't add the remember me
 functionality in the site

 Any ideas???

 Many Thanks for reading.
--~--~-~--~~~---~--~~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments (0 for 1)

2009-09-16 Thread Greg Donald

On Wed, Sep 16, 2009 at 2:05 PM, RubyonRails_newbie
craigwest...@googlemail.com wrote:
 I am running through the RailsSpace tutorial. I'm trying to figure out
 the advanced login section, which in short creates a cookie and an
 authorization token in the users table in the database.

 My trouble is, I'm getting error: Wrong number of arguments (0 for 1)

 the code that has been updated is as follows:

 In ApplicationController:

 before_filter :check_authorization

What does the signature of this check_authorization method look like?
Seems it's expecting an argument you're not sending.


-- 
Greg Donald
http://destiney.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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) in []

2009-07-03 Thread Colin Law

2009/7/3 JannaB mistressja...@hotmail.com:

 I am creating a multiple-selection list box with :

  % form__list1 = [] %
 %= select_tag, options_for_select([A,B,C,D], selected =A),
 html_options = {size = 5, multiple = true}) %

 I get
 wrong number of arguments (0 for 1)
 alluding to form__list1[] . How else should I specify this to not have
 this error? -Janna B

I don't know what form__list1 is for but you have missed the first
parameter for select_tag.  Also when you have an error it is worth
giving more information on the error reported.  When putting code in
an email it is best to copy and paste it if possible so as to
eliminate typos in the mail, and to ensure that the code shown is
exactly as in the app.  You may have done this of course.

Colin







 


--~--~-~--~~~---~--~~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) in []

2009-07-03 Thread Matt Jones



On Jul 3, 12:33 am, JannaB mistressja...@hotmail.com wrote:
 I am creating a multiple-selection list box with :

  % form__list1 = [] %
 %= select_tag, options_for_select([A,B,C,D], selected =A),
 html_options = {size = 5, multiple = true}) %


I'm not sure what the error that you're getting is, but there are
enough in this fragment to go around.

- select_tag shouldn't be followed by a comma; written that way, you
are calling it without arguments.

- select_tag requires the first argument to be the name of the field

- the final argument to options_for_select is positionial; the
selected =  part is not required (nor is it meaningful). Similarly
for html_options. The only thing that both statements will accomplish
is setting local variables to the various array values.

- keys in the options array are traditionally symbols; not really a
bug, but a slightly incorrect idiom.

--Matt Jones
--~--~-~--~~~---~--~~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (1 for 0)

2009-06-04 Thread Frederick Cheung



On Jun 4, 10:33 am, springbok e...@infoware.com.au wrote:
 Hi,

 I hope someone can help me because this is driving me crazy, I've
 spent hours trying to track this down. I'm trying to convert a Rails
 1.1 to Rails 2.3.2 and I'm getting the following error when trying to
 save a many to many relationship. I've double checked all the
 associations, I've used console to test my models and they all work
 ok, I can do manually what I'm trying to do with Rails. There is
 something in the code somewhere outside of the model code that is
 causing this problem and I'm at a loss to track it down.


Have you (or a plugin) overwritten a core method somewhere ?

Fred
 I've traced into the code for has_many_associations.rb:

         def insert_record(record, force = false, validate = true)
           set_belongs_to_association_for(record)
           force ? record.save! : record.save(validate)
         end

 and it blows up on the force ? record.save! : record.save(validate)
 line. Here is the stack trace:

 wrong number of arguments (1 for 0)

 RAILS_ROOT: /var/www/rails/dropzone
 Application Trace | Framework Trace | Full Trace

 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/has_many_association.rb:61:in `save'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/has_many_association.rb:61:in `insert_record'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_proxy.rb:145:in `send'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_proxy.rb:145:in `send'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 autosave_association.rb:291:in `save_collection_association'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 autosave_association.rb:284:in `each'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 autosave_association.rb:284:in `save_collection_association'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 autosave_association.rb:168:in
 `autosave_associated_records_for_booking_options'
 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
 callbacks.rb:180:in `evaluate_method'
 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
 callbacks.rb:180:in `evaluate_method'
 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
 callbacks.rb:180:in `instance_eval'
 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
 callbacks.rb:180:in `evaluate_method'
 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
 callbacks.rb:166:in `call'
 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
 callbacks.rb:93:in `run'
 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
 callbacks.rb:92:in `each'
 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
 callbacks.rb:92:in `send'
 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
 callbacks.rb:92:in `run'
 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
 callbacks.rb:276:in `run_callbacks'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 callbacks.rb:344:in `callback'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 callbacks.rb:283:in `update'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 base.rb:2868:in `create_or_update_without_callbacks'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 callbacks.rb:250:in `create_or_update'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 base.rb:2556:in `save_without_validation!'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 validations.rb:1019:in `save_without_dirty!'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 dirty.rb:87:in `save_without_transactions!'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 transactions.rb:200:in
 `save__without_trace_ActiveRecord___self_class_name__save'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 connection_adapters/abstract/database_statements.rb:136:in
 `transaction'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 transactions.rb:182:in `transaction'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 transactions.rb:200:in
 `save__without_trace_ActiveRecord___self_class_name__save'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 transactions.rb:208:in `rollback_active_record_state!'
 /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 transactions.rb:200:in
 `save__without_trace_ActiveRecord___self_class_name__save'
 /var/www/rails/dropzone/vendor/plugins/newrelic_rpm/lib/new_relic/
 agent/method_tracer.rb:138:in `save__without_trace_ActiveRecord_save'
 /var/www/rails/dropzone/vendor/plugins/newrelic_rpm/lib/new_relic/
 agent/method_tracer.rb:41:in 

[Rails] Re: wrong number of arguments (3 for 2)

2009-03-04 Thread Heinz Strunk

Hey,

try:
date_select(user, birthday, :start_year = 1926, :end_year = 
Time.now.year-13)
-- 
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (3 for 2)

2009-03-04 Thread Frederick Cheung


On 4 Mar 2009, at 01:44, Zqj Zqj wrote:


 Showing vendor/plugins/community_engine/app/views/users/new.html.haml
 where line #40 raised:


Only time i've seen this is with plugins that fiddle with the date  
helpers, globalite may well be one of them

Fred
 wrong number of arguments (3 for 2)

 Extracted source (around line #40):

 37: %label{for=birthdate}
 38:   Birthday:
 39:   %em (Required: you must be at least 13 years old to sign
 up.)
 40: = date_select :user, :birthday, {:start_year = 1926,
 :end_year = Time.now.year - 13}
 41:
 42: %label{for=password}
 43:   Type your password:

 RAILS_ROOT: D:/InstantRails/rails_apps/caigentan
 Application Trace | Framework Trace | Full Trace

 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/helpers/date_helper.rb:651:in
 `select_month'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/helpers/date_helper.rb:651:in
 `send'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/helpers/date_helper.rb:651:in
 `date_or_time_select'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/helpers/date_helper.rb:646:in
 `each'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/helpers/date_helper.rb:646:in
 `date_or_time_select'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/helpers/date_helper.rb:602:in
 `to_date_select_tag_without_error_wrapping'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/helpers/active_record_helper.rb:239:in
 `to_date_select_tag'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/helpers/date_helper.rb:156:in
 `date_select'
 vendor/plugins/community_engine/app/views/users/new.html.haml:40:in
 ` 
 _run_plugin_47vendor47plugins47community_engine47app47views47users47new46html46haml
  
 '
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/haml-2.0.9/lib/haml/ 
 helpers/action_view_mods.rb:165:in
 `call'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/haml-2.0.9/lib/haml/ 
 helpers/action_view_mods.rb:165:in
 `form_for_without_record_identification'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/haml-2.0.9/lib/haml/ 
 helpers.rb:447:in
 `call'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/haml-2.0.9/lib/haml/ 
 helpers.rb:447:in
 `haml_bind_proc'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/helpers/form_helper.rb:317:in
 `fields_for'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/helpers/form_helper.rb:253:in
 `form_for_without_haml'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/haml-2.0.9/lib/haml/ 
 helpers/action_view_mods.rb:171:in
 `form_for_without_record_identification'
 vendor/plugins/community_engine/engine_plugins/simply_helpful/lib/ 
 simply_helpful/form_helper_extensions.rb:15:in
 `send'
 vendor/plugins/community_engine/engine_plugins/simply_helpful/lib/ 
 simply_helpful/form_helper_extensions.rb:15:in
 `form_method_with_record_identification'
 vendor/plugins/community_engine/engine_plugins/simply_helpful/lib/ 
 simply_helpful/form_helper_extensions.rb:5:in
 `form_for'
 vendor/plugins/community_engine/app/views/users/new.html.haml:26:in
 ` 
 _run_plugin_47vendor47plugins47community_engine47app47views47users47new46html46haml
  
 '
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/base.rb:338:in
 `send'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/base.rb:338:in
 `execute'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/template_handlers/compilable.rb:29:in
 `send'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/template_handlers/compilable.rb:29:in
 `render'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/template.rb:35:in
 `render'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/template.rb:22:in
 `render_template'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_view/base.rb:245:in
 `render_file'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_controller/base.rb:1108:in
 `render_for_file'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_controller/base.rb:841:in
 `render_with_no_layout'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_controller/layout.rb:251:in
 `render_without_benchmark'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_controller/benchmarking.rb:51:in
 `render'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/ 
 active_support/core_ext/benchmark.rb:8:in
 `realtime'
 D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ 
 action_controller/benchmarking.rb:51:in
 `render'
 

[Rails] Re: wrong number of arguments (1 for 0)

2009-02-18 Thread jemminger

change
  session(:cart).nil?

to
  session[:cart].nil?

session is not a method call

On Feb 18, 12:30 pm, Sony Sebastian rails-mailing-l...@andreas-s.net
wrote:
 Hello,
         I am new to ruby on rails. When I tried to create a session I am
 getting an error, 'wrong number of arguments (1 for 0)', in my
 controller.

 
  ArgumentError in CustomerController#add_to_cart

 wrong number of arguments (1 for 0)

 RAILS_ROOT: /project/bob_shopping
 Application Trace | Framework Trace | Full Trace

 app/controllers/customer_controller.rb:36:in `session'
 app/controllers/customer_controller.rb:36:in `add_to_cart'

 

 My controller is ...

 def add_to_cart
     if request.post?
       product_id    = params[:product_id]
       quantity = params[:quantity]
       account = get_account()
 error)--- session[:cart] = SessionCart.new(account) if
 session(:cart).nil?
       session[:cart].add_product( product_id)
       if quantity = 2 and quantity = 50
         for i in 1..quantity-1
           session[:cart].add_product(product_id)
         end
       end
       flash[:notice] = 'Your order has been placed.'
       redirect_to :action='index' and return true
     end
   end

 ~~

 Waiting for your valuable reply..
 --
 Posted viahttp://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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (1 for 0)

2009-02-18 Thread Frederick Cheung



On Feb 18, 5:44 pm, jemminger jemmin...@gmail.com wrote:
 change
   session(:cart).nil?

 to
   session[:cart].nil?

 session is not a method call

If we're picking nits it is :-) - you just don't pass any arguments to
it.

Fred
--~--~-~--~~~---~--~~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (1 for 0)

2009-02-18 Thread Rick

It would be helpful to see the CustomerController code for the new
method, but...

I have to assume that new should be called as:

session[:cart] = SessionCart.new() if session(:cart).nil?

On Feb 18, 7:30 am, Sony Sebastian rails-mailing-l...@andreas-s.net
wrote:
 Hello,
         I am new to ruby on rails. When I tried to create a session I am
 getting an error, 'wrong number of arguments (1 for 0)', in my
 controller.

 
  ArgumentError in CustomerController#add_to_cart

 wrong number of arguments (1 for 0)

 RAILS_ROOT: /project/bob_shopping
 Application Trace | Framework Trace | Full Trace

 app/controllers/customer_controller.rb:36:in `session'
 app/controllers/customer_controller.rb:36:in `add_to_cart'

 

 My controller is ...

 def add_to_cart
     if request.post?
       product_id    = params[:product_id]
       quantity = params[:quantity]
       account = get_account()
 error)--- session[:cart] = SessionCart.new(account) if
 session(:cart).nil?
       session[:cart].add_product( product_id)
       if quantity = 2 and quantity = 50
         for i in 1..quantity-1
           session[:cart].add_product(product_id)
         end
       end
       flash[:notice] = 'Your order has been placed.'
       redirect_to :action='index' and return true
     end
   end

 ~~

 Waiting for your valuable reply..
 --
 Posted viahttp://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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments?

2008-12-30 Thread MaD

when you get the error mentioned above, there should be the rails
trace right on the same page (the part where rails tells you in which
line of your code and on which method the error occurred).
--~--~-~--~~~---~--~~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments?

2008-12-30 Thread Jeffrey L. Taylor

Quoting Ryan Ororie rails-mailing-l...@andreas-s.net:
[snip]
   def add_product(product)
 current_item = @items.find {|item| item.product == product}
 if current_item
   current_item.increment_quantity
 else
   @items  CartItem.new(product)
 end
   end
 end
 

Your code is calling the ActiveRecord find() which takes an argument or more.
You are intending the Array method.  It has an alias, detect.  Change the line
above to:

current_item = @items.detect {|item| item.product == product}

Someone on this list answer my similar question a year or two ago.  I pass the
each one, teach one obligation on to you.

Grin,
  Jeffrey

--~--~-~--~~~---~--~~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments?

2008-12-30 Thread MaD

nice.

On 30 Dez., 10:12, Jeffrey L. Taylor r...@abluz.dyndns.org wrote:
 Quoting Ryan Ororie rails-mailing-l...@andreas-s.net:
 [snip]

    def add_product(product)
      current_item = @items.find {|item| item.product == product}
      if current_item
        current_item.increment_quantity
      else
        @items  CartItem.new(product)
      end
    end
  end

 Your code is calling the ActiveRecord find() which takes an argument or more.
 You are intending the Array method.  It has an alias, detect.  Change the line
 above to:

 current_item = @items.detect {|item| item.product == product}

 Someone on this list answer my similar question a year or two ago.  I pass the
 each one, teach one obligation on to you.

 Grin,
   Jeffrey
--~--~-~--~~~---~--~~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments?

2008-12-30 Thread Ryan Ororie

MaD wrote:
 when you get the error mentioned above, there should be the rails
 trace right on the same page (the part where rails tells you in which
 line of your code and on which method the error occurred).

Here is the full trace:

app/models/cart.rb:13:in `initialize'
app/models/cart.rb:13:in `new'
app/models/cart.rb:13:in `add_product'
app/controllers/store_controller.rb:10:in `add_to_cart'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in
 
`send'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in
 
`perform_action_without_filters'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in
 
`call_filter'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in
 
`perform_action_without_benchmark'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in
 
`perform_action_without_rescue'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in
 
`measure'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in
 
`perform_action_without_rescue'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in
 
`perform_action'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in
 
`send'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in
 
`process_without_filters'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in
 
`process_without_session_management_support'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in
 
`process'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in
 
`process'
/Users/rmorourk/.gem/ruby/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in 
`dispatch'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in 
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in 
`synchronize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in 
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in 
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in 
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in 
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in 
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in 
`run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in 
`each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in 
`run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in 
`run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in
 
`load'
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in
 
`load'
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
 
`new_constants_in'
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in
 
`load'
/Users/rmorourk/.gem/ruby/1.8/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:60
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in 
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
 
`require'
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
 
`new_constants_in'
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
 
`require'
/Users/rmorourk/.gem/ruby/1.8/gems/rails-1.2.3/lib/commands/server.rb:39
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in 
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
-- 
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 

[Rails] Re: Wrong number of arguments?

2008-12-30 Thread Freddy Andersen

  def add_product(product)
current_item = @items.find {|item| item.product == product}
if current_item
  current_item.increment_quantity
else
  @items  CartItem.new(product)
end
  end

Try changing this to

  def add_product(product)
current_item = @items.find {|item| item.product == product}
if current_item
  current_item.increment_quantity
else
  item = CartItem.create(product)
  @items  item
end
  end
--~--~-~--~~~---~--~~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments?

2008-12-30 Thread Ryan Ororie

Freddy Andersen wrote:
 def add_product(product)
 current_item = @items.find {|item| item.product == product}
 if current_item
   current_item.increment_quantity
 else
   @items  CartItem.new(product)
 end
   end
 
 Try changing this to
 
   def add_product(product)
 current_item = @items.find {|item| item.product == product}
 if current_item
   current_item.increment_quantity
 else
   item = CartItem.create(product)
   @items  item
 end
   end

This changed my error to:

undefined method `create' for CartItem:Class

Might be worth nothing that when I try to clear the session this is what 
I get:

bio4054059:depot rmorourk$ rake db:sessions:clear
(in /Users/rmorourk/Sites/depot)
/Users/rmorourk/Sites/depot/config/boot.rb:26:Warning: 
Gem::SourceIndex#search support for String patterns is deprecated
bio4054059:depot rmorourk$
-- 
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments?

2008-12-30 Thread Ryan Ororie

It might also be helpful to see my store_controller.rb file:

class StoreController  ApplicationController

  def index
@products = Product.find_products_for_sale
  end

  def add_to_cart
@cart = find_cart
product = Product.find(params[:id])
@cart.add_product(product)
  end

  private
  def find_cart
session[:cart] ||=Cart.new
  end
end

If I am reading the trace right (which I don't know that I am) I think 
the problem is on the @cart.add_product(product) line?
-- 
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments?

2008-12-30 Thread Freddy Andersen

a Sorry I see now I was thinking that the CartItem class was an
activerecord class ... The issue is this:

Here you call a new object of CartItem with a product passed
@items  CartItem.new(product)

But here in the initialize you do not have a argument for
initialize...

class CartItem
  attr_reader :product, :quantity
  def initialize
@product = product
@quantity = 1
  end

Change it to this

class CartItem
  attr_reader :product, :quantity
  def initialize( product )
@product = product
@quantity = 1
  end
--~--~-~--~~~---~--~~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments?

2008-12-29 Thread Matt

You're going to have to isolate what line the error originates from on
your application by going through the Rails trace information,
otherwise we're all going to be here forever trying to figure out what
the problem is.

On Dec 30, 1:22 am, Ryan Ororie rails-mailing-l...@andreas-s.net
wrote:
 I'm going through a tutorial here and running into an error I'm not sure
 how to fix..this is my first foire into sessions.

 Trying to create a shopping cart for a store app. I'm getting this
 error:

 wrong number of arguments (1 for 0)

 RAILS_ROOT: script/../config/..

 Here is my cart_item.rb model:

 class CartItem
   attr_reader :product, :quantity

   def initialize
     @product = product
     @quantity = 1
   end

   def increment_quantity
     @quantity += 1
   end

   def title
     @product.title
   end

   def price
     @product.price * @quantity
   end
 end

 And my cart.rb model:

 class Cart
   attr_reader :items

   def initialize
     @items = []
   end

   def add_product(product)
     current_item = @items.find {|item| item.product == product}
     if current_item
       current_item.increment_quantity
     else
       @items  CartItem.new(product)
     end
   end
 end

 And my add_to_cart.rhtml view:

 h1The shopping cart/h1
 ul
   % for item in @cart.items %
     li%= cart_item.quantity % times; %= h(item.title) %/li
   % end %
 /ul

 When I first tried clicking the add to cart function for a product I got
 an error that method 'product' was undefined but then I did rake
 db:sessions:clear and now I am getting this wrong number of arguments
 error - any ideas?

 Thanks!
 --
 Posted viahttp://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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments?

2008-12-29 Thread Ryan Ororie

Matt wrote:
 You're going to have to isolate what line the error originates from on
 your application by going through the Rails trace information,
 otherwise we're all going to be here forever trying to figure out what
 the problem is.
 
 On Dec 30, 1:22�am, Ryan Ororie rails-mailing-l...@andreas-s.net

How can I do that?
-- 
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-10 Thread Jay Mark

Frederick Cheung wrote:
 On Dec 10, 5:36�am, Jay Mark [EMAIL PROTECTED] wrote:
 Rails?
 Is subselect not supported in Rails?

 
 For the sake of argument you can do
 
 @books = Books.find_by_sql [SELECT * FROM books WHERE title IN
 (SELECT
 title FROM authors WHERE name = ?), params[:author][:name]]
 
 But really whenever you use find_by_sql you should give yourself  a
 long hard look in the mirror. There's almost always a better way.
 
 Fred


Thanks a lot Fred. It works perfect now. Thanks for your help guys.

Cypray

-- 
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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-09 Thread Jay Mark

Here is the result from ruby script/console
 Author.new
= #Author id: nil, name: , title: , book_id: nil

 Book.new
= #Book id: nil, title: , isbn: 





Ryan Bigg wrote:
 Ok... then you're on your own if you don't know how to type ruby
 script/console into a command prompt window and then type some more
 stuff
 -
 Ryan Bigg
 Freelancer
 http://frozenplague.net

-- 
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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-09 Thread Jay Mark

Ryan Bigg wrote:
 And finally, what version of Rails?
 -
 Ryan Bigg
 Freelancer
 http://frozenplague.net

I am using 2.0.2 with mysql database

Cypray
-- 
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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-09 Thread Ryan Bigg

I have no clue. Author.find_by_name should be working when it  
(apparently) is not. Something is broken.
-
Ryan Bigg
Freelancer
http://frozenplague.net







On 10/12/2008, at 8:44 AM, Jay Mark wrote:


 Ryan Bigg wrote:
 And finally, what version of Rails?
 -
 Ryan Bigg
 Freelancer
 http://frozenplague.net

 I am using 2.0.2 with mysql database

 Cypray
 -- 
 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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-09 Thread Jay Mark

Ryan Bigg wrote:
 I have no clue. Author.find_by_name should be working when it
 (apparently) is not. Something is broken.
 -
 Ryan Bigg
 Freelancer
 http://frozenplague.net

I think so too. Thanks for your help.
Why is it so hard to find the correct syntax for doing a subselect in 
Rails?
Is subselect not supported in Rails?

Cypray
-- 
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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-09 Thread Ryan Bigg

It's supported. It's the syntax I showed you before:

Author.find_by_name(Blah).books, will get you all the books by that  
author.
-
Ryan Bigg
Freelancer
http://frozenplague.net







On 10/12/2008, at 3:36 PM, Jay Mark wrote:


 Ryan Bigg wrote:
 I have no clue. Author.find_by_name should be working when it
 (apparently) is not. Something is broken.
 -
 Ryan Bigg
 Freelancer
 http://frozenplague.net

 I think so too. Thanks for your help.
 Why is it so hard to find the correct syntax for doing a subselect in
 Rails?
 Is subselect not supported in Rails?

 Cypray
 -- 
 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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Frederick Cheung


On 8 Dec 2008, at 16:30, Jay Mark wrote:


 I am using Rails 2.0.2 with mysql database
 I am getting this error when running a query with Find_by_sql:

 wrong number of arguments (0 for 1)

 Here are my queries:

 @authors = Author.find_by_sql[SELECT * FROM authors WHERE name = ?',
 name]
 Also
 @books = Books.find_by_sql[SELECT * FROM books where title IN( SELECT
 title FROM authors where name = ?', name)]


 I am passing in 'name' as a parameter and the URL shows the right
 parameter.

 Is the syntax of my queries correct?  What can cause this error?
 I use partial form and I still get the error.

Your syntax isn't right in two ways. You need a space before the [ or  
ruby thinks that you want to call the find_by_sql methods with no  
arguments and then call the [] method on the result, and seconly  
what's in that array isn't right,

@authors = Author.find_by_sql[SELECT * FROM authors WHERE name = ?',  
name]

should be

@authors = Author.find_by_sql [SELECT * FROM authors WHERE name = ?,  
name]

and arguably you shouldn't be using find_by_sql at all here,

@authors = Author.find_all_by_name name

would work just fine

Fred
 Please help

 Cypray
 -- 
 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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Jay Mark

Thanks for your help Fred. The wrong number of argument problem is gone.

The queries are still not working.

Using find_all_by_name give me method not found error

This one below returns no data but gives no error. But it works fine 
when I put it in mysql directly.

@authors = Author.find_by_sql [SELECT * FROM authors WHERE name = ?,
 'name']

Also passing it in as author[:name] returns no data but gives no error, 
just empty rows

@authors = Author.find_by_sql [SELECT * FROM authors WHERE name = ?, 
'author[:name]']

Without the single quote ('') around the 'name', I get undefined local 
variable error.

Does any one know what is wrong with my query?

Also  Rails is rejecting the syntax of the subselect below:

@books = Books.find_by_sql [SELECT * FROM books where title IN( SELECT
title FROM authors where name = ?, 'name')]

It is not accepting '(' or '['  to enclose the inner SELECT

I have tested this also in mysql and it works fine.

Does any one know the correct syntax for a subselect in Rails?

Thanks
Cypray.



Frederick Cheung wrote:
 On 8 Dec 2008, at 16:30, Jay Mark wrote:
 
 Also
 @books = Books.find_by_sql[SELECT * FROM books where title IN( SELECT
 title FROM authors where name = ?', name)]


 I am passing in 'name' as a parameter and the URL shows the right
 parameter.

 Is the syntax of my queries correct?  What can cause this error?
 I use partial form and I still get the error.

 Your syntax isn't right in two ways. You need a space before the [ or
 ruby thinks that you want to call the find_by_sql methods with no
 arguments and then call the [] method on the result, and seconly
 what's in that array isn't right,
 
 @authors = Author.find_by_sql[SELECT * FROM authors WHERE name = ?',
 name]
 
 should be
 
 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name = ?,
 name]
 
 and arguably you shouldn't be using find_by_sql at all here,
 
 @authors = Author.find_all_by_name name
 
 would work just fine
 
 Fred

-- 
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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Frederick Cheung



On Dec 8, 7:31 pm, Jay Mark [EMAIL PROTECTED] wrote:
 Thanks for your help Fred. The wrong number of argument problem is gone.

 The queries are still not working.

 Using find_all_by_name give me method not found error

That should work as long as the argument you  pass it exists (and as
long as Author has a column called name) , but from what you say below
you don't have a local variable called name.

 This one below returns no data but gives no error. But it works fine
 when I put it in mysql directly.

 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name = ?,
  'name']

 Also passing it in as author[:name] returns no data but gives no error,
 just empty rows

Well you've asked for authors whose name is the exact string 'name'.
Presumably you have a variable of some sort with the name you are
searching for ? You should stick that in


 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name = ?,
 'author[:name]']

 Without the single quote ('') around the 'name', I get undefined local
 variable error.

 Does any one know what is wrong with my query?

 Also  Rails is rejecting the syntax of the subselect below:

You're closing the parens in the wrong place. what you pass to
find_by_sql must be
[ A string with all the sql, all, the, substitutions, here]

take a look at the examples in the docs.

Fred

 @books = Books.find_by_sql [SELECT * FROM books where title IN( SELECT
 title FROM authors where name = ?, 'name')]

 It is not accepting '(' or '['  to enclose the inner SELECT

 I have tested this also in mysql and it works fine.

 Does any one know the correct syntax for a subselect in Rails?

 Thanks
 Cypray.



 Frederick Cheung wrote:
  On 8 Dec 2008, at 16:30, Jay Mark wrote:

  Also
  @books = Books.find_by_sql[SELECT * FROM books where title IN( SELECT
  title FROM authors where name = ?', name)]

  I am passing in 'name' as a parameter and the URL shows the right
  parameter.

  Is the syntax of my queries correct?  What can cause this error?
  I use partial form and I still get the error.

  Your syntax isn't right in two ways. You need a space before the [ or
  ruby thinks that you want to call the find_by_sql methods with no
  arguments and then call the [] method on the result, and seconly
  what's in that array isn't right,

  @authors = Author.find_by_sql[SELECT * FROM authors WHERE name = ?',
  name]

  should be

  @authors = Author.find_by_sql [SELECT * FROM authors WHERE name = ?,
  name]

  and arguably you shouldn't be using find_by_sql at all here,

  @authors = Author.find_all_by_name name

  would work just fine

  Fred

 --
 Posted viahttp://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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Jay Mark

Thanks again Fred.
NO, I am not asking for the author whose name is the exact string 
'name'.
Name is the attribute or column in the authors table which has name 
values like James, John, etc. The user will select a name, say John, 
then I am passing that name as a condition to the query.
After a submit button is clicked, the URL shows this:
http://localhost:3000/authors/show?author[name]=Johncommit=Submit

I can't stick the name value in because it has to come dynamically to 
the controller. Name is not unique in the table

I am still looking for the correct syntax for this:
@authors = Author.find_by_sql [SELECT * FROM authors WHERE name = ?,
 'author[:name]']



and this subselect:

@books = Books.find_by_sql [SELECT * FROM books where title IN( SELECT
title FROM authors where name = ?, 'name')]

I can't find it in the Docs.
Please send me any pointers.
Thanks

Cypray











Frederick Cheung wrote:
 On Dec 8, 7:31�pm, Jay Mark [EMAIL PROTECTED] wrote:
 Thanks for your help Fred. The wrong number of argument problem is gone.

 The queries are still not working.

 Using find_all_by_name give me method not found error

 That should work as long as the argument you  pass it exists (and as
 long as Author has a column called name) , but from what you say below
 you don't have a local variable called name.
 
 This one below returns no data but gives no error. But it works fine
 when I put it in mysql directly.

 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name = ?,
 �'name']

 Also passing it in as author[:name] returns no data but gives no error,
 just empty rows

 Well you've asked for authors whose name is the exact string 'name'.
 Presumably you have a variable of some sort with the name you are
 searching for ? You should stick that in
 
 
 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name = ?,
 'author[:name]']

 Without the single quote ('') around the 'name', I get undefined local
 variable error.

 Does any one know what is wrong with my query?

 Also �Rails is rejecting the syntax of the subselect below:

 You're closing the parens in the wrong place. what you pass to
 find_by_sql must be
 [ A string with all the sql, all, the, substitutions, here]
 
 take a look at the examples in the docs.
 
 Fred

-- 
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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Frederick Cheung


On 8 Dec 2008, at 22:53, Jay Mark wrote:


 Thanks again Fred.
 NO, I am not asking for the author whose name is the exact string
 'name'.
 Name is the attribute or column in the authors table which has name
 values like James, John, etc. The user will select a name, say John,
 then I am passing that name as a condition to the query.
 After a submit button is clicked, the URL shows this:
 http://localhost:3000/authors/show?author[name]=Johncommit=Submit

 I can't stick the name value in because it has to come dynamically to
 the controller. Name is not unique in the table

 I am still looking for the correct syntax for this:
 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name = ?,
 'author[:name]']

Author.find_all_by_name author[:name]
In general, whereever I wrote name in the previous suggestions you can  
just write author[:name]






 and this subselect:

 @books = Books.find_by_sql [SELECT * FROM books where title  
 IN( SELECT
 title FROM authors where name = ?, 'name')]


Like I said, you've not to write it in the form
Books.find_by_sql [some_sql_statement, author[:name]]

Seems to me like you would benefit from going back to some basic ruby  
stuff.

Fred
 I can't find it in the Docs.
 Please send me any pointers.
 Thanks

 Cypray











 Frederick Cheung wrote:
 On Dec 8, 7:31�pm, Jay Mark [EMAIL PROTECTED]  
 wrote:
 Thanks for your help Fred. The wrong number of argument problem is  
 gone.

 The queries are still not working.

 Using find_all_by_name give me method not found error

 That should work as long as the argument you  pass it exists (and as
 long as Author has a column called name) , but from what you say  
 below
 you don't have a local variable called name.

 This one below returns no data but gives no error. But it works fine
 when I put it in mysql directly.

 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name  
 = ?,
 �'name']

 Also passing it in as author[:name] returns no data but gives no  
 error,
 just empty rows

 Well you've asked for authors whose name is the exact string 'name'.
 Presumably you have a variable of some sort with the name you are
 searching for ? You should stick that in


 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name  
 = ?,
 'author[:name]']

 Without the single quote ('') around the 'name', I get undefined  
 local
 variable error.

 Does any one know what is wrong with my query?

 Also �Rails is rejecting the syntax of the subselect below:

 You're closing the parens in the wrong place. what you pass to
 find_by_sql must be
 [ A string with all the sql, all, the, substitutions, here]

 take a look at the examples in the docs.

 Fred

 -- 
 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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Ryan Bigg

If it's coming in dynamically, wouldn't it be params[:author][:name]  
or something similar? A bit hard to guess without seeing more code.
-
Ryan Bigg
Freelancer
http://frozenplague.net







On 09/12/2008, at 9:30 AM, Frederick Cheung wrote:



 On 8 Dec 2008, at 22:53, Jay Mark wrote:


 Thanks again Fred.
 NO, I am not asking for the author whose name is the exact string
 'name'.
 Name is the attribute or column in the authors table which has name
 values like James, John, etc. The user will select a name, say John,
 then I am passing that name as a condition to the query.
 After a submit button is clicked, the URL shows this:
 http://localhost:3000/authors/show?author[name]=Johncommit=Submit

 I can't stick the name value in because it has to come dynamically to
 the controller. Name is not unique in the table

 I am still looking for the correct syntax for this:
 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name  
 = ?,
 'author[:name]']

 Author.find_all_by_name author[:name]
 In general, whereever I wrote name in the previous suggestions you can
 just write author[:name]






 and this subselect:

 @books = Books.find_by_sql [SELECT * FROM books where title
 IN( SELECT
 title FROM authors where name = ?, 'name')]


 Like I said, you've not to write it in the form
 Books.find_by_sql [some_sql_statement, author[:name]]

 Seems to me like you would benefit from going back to some basic ruby
 stuff.

 Fred
 I can't find it in the Docs.
 Please send me any pointers.
 Thanks

 Cypray











 Frederick Cheung wrote:
 On Dec 8, 7:31�pm, Jay Mark [EMAIL PROTECTED]
 wrote:
 Thanks for your help Fred. The wrong number of argument problem is
 gone.

 The queries are still not working.

 Using find_all_by_name give me method not found error

 That should work as long as the argument you  pass it exists (and as
 long as Author has a column called name) , but from what you say
 below
 you don't have a local variable called name.

 This one below returns no data but gives no error. But it works  
 fine
 when I put it in mysql directly.

 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name
 = ?,
 �'name']

 Also passing it in as author[:name] returns no data but gives no
 error,
 just empty rows

 Well you've asked for authors whose name is the exact string 'name'.
 Presumably you have a variable of some sort with the name you are
 searching for ? You should stick that in


 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name
 = ?,
 'author[:name]']

 Without the single quote ('') around the 'name', I get undefined
 local
 variable error.

 Does any one know what is wrong with my query?

 Also �Rails is rejecting the syntax of the subselect below:

 You're closing the parens in the wrong place. what you pass to
 find_by_sql must be
 [ A string with all the sql, all, the, substitutions, here]

 take a look at the examples in the docs.

 Fred

 -- 
 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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Frederick Cheung


On 8 Dec 2008, at 23:36, Ryan Bigg wrote:


 If it's coming in dynamically, wouldn't it be params[:author][:name]
 or something similar? A bit hard to guess without seeing more code.

D'oh of course, not sure why I wrote author[:name]

Fred

 -
 Ryan Bigg
 Freelancer
 http://frozenplague.net







 On 09/12/2008, at 9:30 AM, Frederick Cheung wrote:



 On 8 Dec 2008, at 22:53, Jay Mark wrote:


 Thanks again Fred.
 NO, I am not asking for the author whose name is the exact string
 'name'.
 Name is the attribute or column in the authors table which has  
 name
 values like James, John, etc. The user will select a name, say John,
 then I am passing that name as a condition to the query.
 After a submit button is clicked, the URL shows this:
 http://localhost:3000/authors/show?author[name]=Johncommit=Submit

 I can't stick the name value in because it has to come dynamically  
 to
 the controller. Name is not unique in the table

 I am still looking for the correct syntax for this:
 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name
 = ?,
 'author[:name]']

 Author.find_all_by_name author[:name]
 In general, whereever I wrote name in the previous suggestions you  
 can
 just write author[:name]






 and this subselect:

 @books = Books.find_by_sql [SELECT * FROM books where title
 IN( SELECT
 title FROM authors where name = ?, 'name')]


 Like I said, you've not to write it in the form
 Books.find_by_sql [some_sql_statement, author[:name]]

 Seems to me like you would benefit from going back to some basic ruby
 stuff.

 Fred
 I can't find it in the Docs.
 Please send me any pointers.
 Thanks

 Cypray











 Frederick Cheung wrote:
 On Dec 8, 7:31�pm, Jay Mark [EMAIL PROTECTED]
 wrote:
 Thanks for your help Fred. The wrong number of argument problem is
 gone.

 The queries are still not working.

 Using find_all_by_name give me method not found error

 That should work as long as the argument you  pass it exists (and  
 as
 long as Author has a column called name) , but from what you say
 below
 you don't have a local variable called name.

 This one below returns no data but gives no error. But it works
 fine
 when I put it in mysql directly.

 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name
 = ?,
 �'name']

 Also passing it in as author[:name] returns no data but gives no
 error,
 just empty rows

 Well you've asked for authors whose name is the exact string  
 'name'.
 Presumably you have a variable of some sort with the name you are
 searching for ? You should stick that in


 @authors = Author.find_by_sql [SELECT * FROM authors WHERE name
 = ?,
 'author[:name]']

 Without the single quote ('') around the 'name', I get undefined
 local
 variable error.

 Does any one know what is wrong with my query?

 Also �Rails is rejecting the syntax of the subselect below:

 You're closing the parens in the wrong place. what you pass to
 find_by_sql must be
 [ A string with all the sql, all, the, substitutions, here]

 take a look at the examples in the docs.

 Fred

 -- 
 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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Jay Mark

Thanks guys, the first query is working fine now.

Rails is still rejecting the syntax of this subselect:

@books = Books.find_by_sql [SELECT * FROM books WHERE title IN SELECT 
title FROM authors WHERE name = ?, params[:author][:name]]

I know the inner select should be in (), but its not taking it where I 
put it.
Can any one see what the problem is?
Thanks
Cypray







Frederick Cheung wrote:
 On 8 Dec 2008, at 23:36, Ryan Bigg wrote:
 

 If it's coming in dynamically, wouldn't it be params[:author][:name]
 or something similar? A bit hard to guess without seeing more code.
 
 D'oh of course, not sure why I wrote author[:name]
 
 Fred

-- 
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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Ryan Bigg (Radar)
Stop using find_by_sql!

You can just do:

author = Author.find_by_name(params[:author][:name])
books = author.books.find(:all, :select = title)

--~--~-~--~~~---~--~~
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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Jay Mark

I am using find_by_sql because I get this error when I use find_by_name 
or
find_all_by_name

undefined method `find_by_name' for #Class:

I get it again when I put in the code in the last post.
Is there a way to solve the undefined method problem?

Cypray







Ryan Bigg wrote:
 Stop using find_by_sql!
 
 You can just do:
 
 author = Author.find_by_name(params[:author][:name])
 books = author.books.find(:all, :select = title)

-- 
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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Ryan Bigg

pastie your models please
-
Ryan Bigg
Freelancer
http://frozenplague.net







On 09/12/2008, at 2:14 PM, Jay Mark wrote:


 I am using find_by_sql because I get this error when I use  
 find_by_name
 or
 find_all_by_name

 undefined method `find_by_name' for #Class:

 I get it again when I put in the code in the last post.
 Is there a way to solve the undefined method problem?

 Cypray







 Ryan Bigg wrote:
 Stop using find_by_sql!

 You can just do:

 author = Author.find_by_name(params[:author][:name])
 books = author.books.find(:all, :select = title)

 -- 
 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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Jay Mark

Here are my models:

class Author  ActiveRecord::Base


belongs_to :book

end

class Book  ActiveRecord::Base




 has_many :authors


end







Ryan Bigg wrote:
 pastie your models please
 -
 Ryan Bigg
 Freelancer
 http://frozenplague.net

-- 
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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Ryan Bigg

And in the console do Author.new and Book.new and show me the output  
of each please.
-
Ryan Bigg
Freelancer
http://frozenplague.net







On 09/12/2008, at 2:44 PM, Jay Mark wrote:


 Here are my models:

 class Author  ActiveRecord::Base


 belongs_to :book

 end

 class Book  ActiveRecord::Base




 has_many :authors


 end







 Ryan Bigg wrote:
 pastie your models please
 -
 Ryan Bigg
 Freelancer
 http://frozenplague.net

 -- 
 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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Jay Mark

It says:
Author.new is not recognized as an internal or external command,
operable program or batch file.

same for Book.




Ryan Bigg wrote:
 And in the console do Author.new and Book.new and show me the output
 of each please.
 -
 Ryan Bigg
 Freelancer
 http://frozenplague.net

-- 
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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Ryan Bigg

I meant doing it in ruby script/console, not just in the command
-
Ryan Bigg
Freelancer
http://frozenplague.net







On 09/12/2008, at 3:03 PM, Jay Mark wrote:


 It says:
 Author.new is not recognized as an internal or external command,
 operable program or batch file.

 same for Book.




 Ryan Bigg wrote:
 And in the console do Author.new and Book.new and show me the output
 of each please.
 -
 Ryan Bigg
 Freelancer
 http://frozenplague.net

 --  
 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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: wrong number of arguments (0 for 1) error.... Help!!!

2008-12-08 Thread Ryan Bigg

Ok... then you're on your own if you don't know how to type ruby  
script/console into a command prompt window and then type some more  
stuff
-
Ryan Bigg
Freelancer
http://frozenplague.net







On 09/12/2008, at 3:16 PM, Jay Mark wrote:


 I am using InstantRails. All I have is the command
 The Open Ruby Console Window gives me the command window



 Ryan Bigg wrote:
 I meant doing it in ruby script/console, not just in the command
 -
 Ryan Bigg
 Freelancer
 http://frozenplague.net

 -- 
 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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments (2 of 0)

2008-10-24 Thread Thierry Delbart

Juste before trying to migrate thie table clubs, I did it fine with 
league:

class CreateLeagues  ActiveRecord::Migration
  def self.up
create_table :leagues do |t|
  t.columns :name, :string
  t.columns :ref, :string
  t.columns :description, :string
  t.columns :category, :string

  t.timestamps
end
  end

  def self.down
drop_table :leagues
  end
end
-- 
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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---



[Rails] Re: Wrong number of arguments (2 of 0)

2008-10-24 Thread Philip Hallstrom


On Oct 24, 2008, at 9:40 AM, Thierry Delbart wrote:


 Juste before trying to migrate thie table clubs, I did it fine with
 league:

 class CreateLeagues  ActiveRecord::Migration
  def self.up
create_table :leagues do |t|
  t.columns :name, :string
  t.columns :ref, :string
  t.columns :description, :string
  t.columns :category, :string

Shouldn't that be t.column? (no 's').  Or maybe even...

t.string :name




  t.timestamps
end
  end

  def self.down
drop_table :leagues
  end
 end
 --  
 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 rubyonrails-talk@googlegroups.com
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
-~--~~~~--~~--~--~---