RailsCasts Pro episodes are now free!

Learn more or hide this

seadaniel's Profile

GitHub User: seadaniel

Comments by

Avatar

Does slug support traditional Chinese character?

here is the code

/app/models/article.rb
class Article < ActiveRecord::Base
  extend FriendlyId
  friendly_id :name, use: :slugged
end

Let's say I create an new article with Chinese title.

It seems friendlyId is unable to save the Chinese title in slug column. So the URL still show the id of the article.

If I do this

/app/models/article.rb
class Article < ActiveRecord::Base
  extend FriendlyId
  friendly_id :name
end

It works but I have to ensure no duplicate name.

Any way to solve this?

Avatar

@Bardwin

Your example works very well. Thank you!

How to show a notice like "no record match" when there is no match record according to the input value?

Avatar

I am building this functionality into my projects.

I would like to have the order of all the parent messages from new to old and the order of child messages from old to new.

Here is my code

model/message.rb
default_scope order: 'microposts.created_at DESC'
messages/index.html.erb
<%= nested_microposts @microposts.arrange(:order => :created_at) %>

the code in model/message.rb seems to override .arrange(:order => :created_at)

So the order of all the messages is from new to old and the nested function doesn't work.

Can I arrange the order of all the messages as what I say??