spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

rails newbie: upon resource creation, render :location returns localhost:3000/users.id instead of localhost:3000/users/id


Here is the solution:

def create
  user = User.create(name: params[:user])
  render :json =>
JSON.pretty_generate(user.as_json), :status =>
200, content_type: 'application/json', location:
url_for(user) # you did mistake here.
end

I hope this will help!


Categories : Ruby On Rails

Related to : rails newbie: upon resource creation, render :location returns localhost:3000/users.id instead of localhost:3000/users/id
AddToRole() returns "User name can only contain letters or digits" only when users email address contains a dash
According to your code AllowOnlyAlphanumericUserNames = false only calling when you calling the method 'Create' of ApplicationUserManager. So that you make sure that method calls before accessing um.AddToRole() method. Get userManager from owin context like below then call your menthods. var userManager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>(); userManager.AddT

Categories : C#
Admin can't delete users. Ruby on Rails 3 - Michael Hartl
Fixed the problem. After calling jquery (my fault) and changed the link: <%= link_to "delete", user, :method => :destroy, :confirm => "You sure?", :title => "Delete #{user.name}" %> to: <%= link_to "delete", user, :method => :delete, :confirm => "You sure?", :title => "Delete #{user.name}" %> The link started working ok, with both flashes messages and the delete

Categories : Ruby On Rails
Ruby on Rails & Devise, change 'users/sign_in' to 'sign-in' using omniauth_callbacks and registrations
You need to tell Devise to skip session ULRs. devise_for :users :controllers => { :registrations => 'registrations', :omniauth_callbacks => "authentications" }, :skip => [:sessions] devise_scope :user do put 'update_plan', :to => 'registrations#update_plan' put 'update_card', :to => 'registrations#update_card' put 'charge', :to => 'registrations#charge' get

Categories : Ruby On Rails
Lamp on ubuntu 14.04 .Only want localhost - how?
Well you don't have to worry too much about this, but there is a solution to be sure that is only localhost. You need to configure your Apache to listen only to your localhost address and port. The solution is a bit old, but I don't have Lamp installed on my computer so you have to try it and tell me if it works. This can be done by editing the file: /etc/apache2/ports.conf You can do that w

Categories : Linux
Deezer Javascript SDK on localhost
You can try with : channelUrl: 'http://yourAppDomain.com/channel.php' or channelUrl: 'http://yourAppDomain.com/channel.html

Categories : Javascript
Recently Add
Groups and Users has many oder has many through?
Rails format specifier differences
Capistrano can not create symlinks: file exist
Admin can't delete users. Ruby on Rails 3 - Michael Hartl
Don't show user name who create post
Using Wicked with Devise (2 step signup process)
RubyOnRails Rake test failures
Rails session start event handler
Why ActiveModel::ForbiddenAttributesError error?
How can i track the issue in production RAILS
Cannot install spree gem - ERROR: invalid gem: package is corrupt
Why are the nested resources for Devise authentication not working?
Rails Devise - how to open access to the site root
Rails: respond_with the same template for two methods
rails with postgresl database "role postgres does not exist"
Instance variable in Rails helper not set
Monkey patch rails 3.2 rake task
Rails_admin: Should I have admin_user or user with admin role to manage users and admin panel
undefined method `attachments' for nil:NilClass
Memory usage increase with Ruby 2.1 versus Ruby 2.0 or 1.9
Can a Rails app be deployed without using Heroku Toolbelt? If so, how?
Enable random access to collection with MongoDB
libmysqlclient-dev installation fails
undefined method `name' for nil:NilClass. Can't find @followed.name but @followed is set
Allowing an arbitrary domain and subdomain in session_store.rb
Pushmeup Gem - Can't send push notifications in Active Admin model
Rails console does not start
GitHub Import: Could not locate Gemfile
AWS::S3::PermanentRedirect in SongsController#index "The bucket you are attempting to access must be addressed using the specified endpoint"
automatically create ActiveRecord parent for association
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.