Hey all, I installed the devise plugin and I''m sure it''s fully installed. I have a popup where user creates an account, including email, password, and password confirmation. When they click submit, I use jquery''s .ajax method: $.ajax({ url: $(''#dialog-form form:first'').attr(''action''), method: ''POST'', data: $(''#dialog-form form:first'').serialize(), beforeSend: function(data){ $(''#headerHome'').html(''Loading...''); }, success: function() { alert("success"); }, failure: function() { alert("failure"); } }); That action attribute I inspect with firebug, and it''s pointing to this link: /users Although in the partial, I specify /users/create: <%= form_for :user, :url => { :controller => "users", :action => "create" } do |f| %> <%= f.label :email, ''Email'' %>: <%= f.text_field :email, :id => "email" %><br /> <%= f.label :password, ''password'' %>: <%= f.password_field :password, :id => "password" %><br /> <%= f.label :password_confirmation, ''password_confirmation'' %>: <%= f.password_field :password_confirmation %><br /> <% end %> The create method of my user''s controller contains this: def create @user = User.new(params[:user]) if @user.save respond_to do |format| format.json { render :json => @user.to_json, :status => 200 } format.xml { head :ok } format.html { redirect_to :action => :index } end else respond_to do |format| format.json { render :text => "Could not create user", :status => :unprocessable_entity } # placeholder format.xml { head :ok } format.html { render :action => :new, :status => :unprocessable_entity } end end end Basically, all that happens when I click submit is a piece of html renders on page "loading..." courtesy of the beforeSend callback function. But it just hangs there. The success is never called and the record is never written to the database. I''m not sure what the problem could be. Thanks for response. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I actually now hard code the create method I want to invoke: var options = { type: ''POST'', url: "users/create", dataType: ''json'', data: $(''#sign-in form:first'').serialize(), error: function(xhr, textStatus, errorThrown) { alert(''An error occurred! '' + errorThrown); }, success: function(data, textStatus) { $(''body'').append( data ); } }; $.ajax( options ); The server output is this: Started POST "/users/create" for 127.0.0.1 at 2011-03-08 14:01:30 -0500 ActionController::RoutingError (No route matches "/users/create"): The JavaScript allert triggers: "An eror occurred! undefined" I have this in routes: devise_for :user resources :users Any idea what''s going on? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I modified the routes to point to controller. But now I get this: Started POST "/users/create" for 127.0.0.1 at 2011-03-08 14:21:21 -0500 Processing by UsersController#create as JSON SQL (177.7ms) BEGIN SQL (1.6ms) ROLLBACK Rendered text template (0.0ms) Completed 422 Unprocessable Entity in 290ms (Views: 47.3ms | ActiveRecord: 179.3ms) this is create method: def create @user = User.new(params[:user]) if @user.save respond_to do |format| format.json { render :json => @user.to_json, :status => 200 } format.xml { head :ok } format.html { redirect_to :action => :index } end else respond_to do |format| format.json { render :text => "Could not create user", :status => :unprocessable_entity } # placeholder format.xml { head :ok } format.html { render :action => :new, :status => :unprocessable_entity } end end end -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Resolved. I had to post to user model, which triggers registration controller. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Can you show how you posted to the user model? On Tuesday, March 8, 2011 12:06:18 PM UTC-8, Ruby-Forum.com User wrote:> > Resolved. I had to post to user model, which triggers registration > controller. > > -- > Posted via http://www.ruby-forum.com/. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/NcVsmlppkVoJ. For more options, visit https://groups.google.com/groups/opt_out.