Reputation: 654
I'm new to configuring Rails applications in production mode. My Rails application is working correctly, but when I try to run it in production mode it crashes at startup:
rails s
=> Booting WEBrick
=> Rails 4.0.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
here everything is fine, and:
RAILS_ENV=production rails c
/Users/dawid/.rvm/gems/[email protected]/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require': /Users/dawid/workspace/demioorg/Dineria/backend/app/controllers/users/users_controller.rb:6: syntax error, unexpected ':', expecting keyword_end (SyntaxError)
render_status: 200,
I'm just wondering why it works in development mode and not in production mode? What can cause that error?
EDIT:
class Users::UsersController < Devise::SessionsController
respond_to :json
def is_user
if current_user.present?
render_status: 200,
json: {
success: !User.find_by_name(params[:name]).blank?
}
end
end
end
Upvotes: 1
Views: 454
Reputation: 3580
Try this format instead:
render :status => 200,
:json => {success: User.exists?(:name => params[:name])}
I think it looks prettier, and is more logical.
Also .exists?
looks a little better than your code.
Upvotes: 1
Reputation: 1793
The Rails documentation shows how to use the :status
option for render
:
2.2.11.4 The :status Option
Rails will automatically generate a response with the correct HTTP status code (in most cases, this is 200 OK). You can use the :status option to change this:
render status: 500
render status: :forbidden
Upvotes: 1