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