What does `:location => …` and `head :ok` mean in the ‘respond_to’ format statement?

render … :location => @user will set the HTTP location header to inform the client of the location of the newly created resource (that is, its URL) head :ok sets render to return an empty response (so just the header, no body) with status 200. head :ok is shorthand for render nothing: true, status: :ok. … Read more

ActionController::UnknownFormat

Update the create action as below: def create … respond_to do |format| if @reservation.save format.html do redirect_to “https://stackoverflow.com/” end format.json { render json: @reservation.to_json } else format.html { render ‘new’} ## Specify the format in which you are rendering “new” page format.json { render json: @reservation.errors } ## You might want to specify a json … Read more

Given a class, see if instance has method (Ruby)

I don’t know why everyone is suggesting you should be using instance_methods and include? when method_defined? does the job. class Test def hello; end end Test.method_defined? :hello #=> true NOTE In case you are coming to Ruby from another OO language OR you think that method_defined means ONLY methods that you defined explicitly with: def … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)