Hi Philip,  I tried your code:

  def create
    name = params[:topic][:name].titleize
    @topic = Topic.find_or_create_by_name(name)
    current_user.topics << @topic
    if @topic.save
      redirect_to @topic, :notice => 'Topic was successfully created.'
    else
      render :action => "new"
    end
  end

But now I get this if a topic has already been created:

'Validation failed: User has already been taken'

> What is visible?  If visible is related to the user's ability to see
> that topic then it shouldn't be set in the topic itself.
> You'll need an intermediate model (look up has many through) to handle
> that.

Visible will be used like a soft-delete, that only admin users will be
able to modify. By default all topics are visible, but if a topic is
against our rules :visible will be changed to false. That way it will
not show (to site visitors) and it will also catch any future violations
(as it's already been created).

> Take a look at the titleize() method and get rid of hashtag entirely...

Titleize only capitalizes the first letter of each word... I want to
remove the space too, so it because a #hastag :-)

-- 
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.

Reply via email to