Add default_sort_key field to users.

This commit is contained in:
Ibrahim Awwal 2012-08-28 22:43:05 -07:00
Родитель 1e4f86a4ee
Коммит 4aebb3a28a
2 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -48,7 +48,7 @@ put "#{APIPREFIX}/users/:user_id" do |user_id|
if not user
user = User.new(external_id: user_id)
end
user.update_attributes(params.slice(*%w[username email]))
user.update_attributes(params.slice(*%w[username email default_sort_key]))
if user.errors.any?
error 400, user.errors.full_messages.to_json
else

Просмотреть файл

@ -6,7 +6,8 @@ class User
field :external_id, type: String
field :username, type: String
field :email, type: String
field :default_sort_key, type: String, default: "date"
has_many :comments, inverse_of: :author
has_many :comment_threads, inverse_of: :author
has_many :activities, class_name: "Notification", inverse_of: :actor
@ -62,7 +63,8 @@ class User
"follower_ids" => subscriptions_as_source.map(&:subscriber_id),
"id" => id,
"upvoted_ids" => upvoted_ids,
"downvoted_ids" => downvoted_ids)
"downvoted_ids" => downvoted_ids,
"default_sort_key" => default_sort_key)
end
if params[:course_id]
hash = hash.merge("threads_count" => comment_threads.where(course_id: params[:course_id]).count,