I think i''m doing something quite simple here but can;t quite get it: 
I
had a load of creation logic in my controller that i decided to move to
the model, under the ''skinny controller'' principle.  So, my
controller
is now passing through the results from a form page, and another
argument of session[:user], to the model constructor:
#controller method
  def create
    if @article = Article.new params[:article], :user => session[:user]
      flash[:notice] = ''Article was successfully created.''
      redirect_to :action => ''list''
    else
      render :action => ''new''
    end
  end
#model constructor
  def initialize(params = {})
    super
    if self.title == ""
      self.title
(Hpricot(open(@article.url))/"title").first.inner_html
    end
    self.added_at = DateTime.now.to_s
    self.user_id = params[:user]
    self.points = 1
    return self.save
  end
But i''m getting an error that looks like a basic syntax error from the
controller:
app/controllers/article_controller.rb:23: syntax error, unexpected
tIDENTIFIER, expecting kTHEN or '':'' or ''\n''
or '';''
    if @article = Article.new params[:article], :user => session[:user]
Can anyone see what''s wrong with my controller constructor call?
thanks in advance
max
-- 
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Max Williams wrote:> if @article = Article.new params[:article], :user => session[:user]Try this: if @article = Article.new(params[:article], :user => session[:user]) Lutz -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Lutz Horn wrote:> Max Williams wrote: >> if @article = Article.new params[:article], :user => session[:user] > > Try this: > > if @article = Article.new(params[:article], :user => session[:user]) > > Lutzi actually tried that already, no joy... -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
>> Try this: >> >> if @article = Article.new(params[:article], :user => session[:user])Actually i just tried this again and it worked this time (buh? sorry), but now i''m having problems in the model getting stuff out of the params: this line in initialize is having a problem: self.user_id = params[:user] getting a nil object error "while evaluating nil.[]" - it looks like params has been lost or something by the time i get to this line...I must be passing :user through badly somehow. Do you know why? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---