- default_lang = @user.preferences.where(:k => "diary.default_language").first
- lang_code = default_lang ? default_lang.v : @user.preferred_language
- @diary_entry = DiaryEntry.new(:language_code => lang_code)
+ default_lang = current_user.preferences.where(:k => "diary.default_language").first
+ lang_code = default_lang ? default_lang.v : current_user.preferred_language
+ @diary_entry = DiaryEntry.new(entry_params.merge(:language_code => lang_code))
redirect_to :action => "view", :id => params[:id]
elsif params[:diary_entry] && @diary_entry.update_attributes(entry_params)
redirect_to :action => "view", :id => params[:id]
redirect_to :action => "view", :id => params[:id]
elsif params[:diary_entry] && @diary_entry.update_attributes(entry_params)
redirect_to :action => "view", :id => params[:id]
Notifier.diary_comment_notification(@diary_comment, user).deliver_now
end
end
# Add the commenter to the subscribers if necessary
Notifier.diary_comment_notification(@diary_comment, user).deliver_now
end
end
# Add the commenter to the subscribers if necessary
redirect_to :action => "view", :display_name => diary_entry.user.display_name, :id => diary_entry.id
rescue ActiveRecord::RecordNotFound
redirect_to :action => "view", :display_name => diary_entry.user.display_name, :id => diary_entry.id
rescue ActiveRecord::RecordNotFound
redirect_to :action => "view", :display_name => diary_entry.user.display_name, :id => diary_entry.id
rescue ActiveRecord::RecordNotFound
redirect_to :action => "view", :display_name => diary_entry.user.display_name, :id => diary_entry.id
rescue ActiveRecord::RecordNotFound
@description = I18n.t("diary_entry.feed.user.description", :user => user.display_name)
@link = "http://#{SERVER_URL}/user/#{user.display_name}/diary"
else
@description = I18n.t("diary_entry.feed.user.description", :user => user.display_name)
@link = "http://#{SERVER_URL}/user/#{user.display_name}/diary"
else
# return permitted diary entry parameters
def entry_params
params.require(:diary_entry).permit(:title, :body, :language_code, :latitude, :longitude)
# return permitted diary entry parameters
def entry_params
params.require(:diary_entry).permit(:title, :body, :language_code, :latitude, :longitude)
# require that the user is a administrator, or fill out a helpful error message
# and return them to the user page.
def require_administrator
# require that the user is a administrator, or fill out a helpful error message
# and return them to the user page.
def require_administrator
@lon = params[:lon] || -0.1
@lat = params[:lat] || 51.5
@zoom = params[:zoom] || 4
else
@lon = params[:lon] || -0.1
@lat = params[:lat] || 51.5
@zoom = params[:zoom] || 4
else