Displaying 12 results from an estimated 12 matches for "users_url".
2009 Jan 16
16
Testing arbitrary post action parameters
I am working on our (newly renamed) authentication feature. The current
scenario is:
Scenario: Non-administrators should not set administrator ability
Given I have no users
And I add a user named "admin" as an administrator
And I add a user named "myuser" as not an administrator
When the user named "myuser" authenticates
And the user
2012 Sep 18
4
"best practices" for Rails serving RESTful JSON services for use by AngularJS, Ember.js, etc.
...if can_create?
respond_with(errors: [''Access denied to create #{self.class.name}''],
status: forbidden)
end
begin
@company = Company.new(params[:company])
consume! @company
if @company.errors
respond_with(errors: [@company.errors], location: users_url,
status: unprocessable_entity)
else
respond_with(@company, location: users_url, status: created)
end
rescue
puts $!.inspect, $@
# TODO: add support for other formats
respond_to do |format|
format.json { render json: {errors: [$!.message]}, status:...
2007 Mar 14
11
path vs. url
When using named RESTful routes, when should one use the
generated ..._path helpers, and when the ..._url helpers? Say I did
this in routes.rb:
map.resources :users
Where should I use users_path, new_user_path, etc., and where should I
use users_url, new_user_url...?
Thanks!
Steve
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To...
2008 Jan 17
4
multiple views, and some routers
...when I type /users/1 search for the
user with id = 1
how do i call the list.html.erb page? because, when i type /users/list i
get an error because it''s trying to search for an id = list (?)
what would be the correct way to map this on routers.rb ?
i have some doubts about the users_path, users_url, when scaffold
generates the page he calls new_user_path for example. I didn''t
understand how that is possible.
If i creat that list.html.erb page on the users folder, will i be able
to call an list_user_path ?
Sorry if my questions look a little too beginner, maybe i missundertood
someth...
2012 Sep 17
1
require current_password to update user information
...update action looks like
I''m currently using rails 3.2 with the basic has_secured_password
authentication that comes with it.
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to users_url, notice: "User #{@user.name}
was successfully updated." }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @user.errors, status:
:unprocessable_entity }
end
end
e...
2011 May 17
6
Nested Resource w/ Collection
...format.json { render :json => @user }
end
end
# GET /users/1/edit
def edit
@user = User.find(params[:id])
end
# POST /users
# POST /users.json
def create
@user = User.new(params[:user])
respond_to do |format|
if @user.save
format.html { redirect_to(users_url,
:notice => "User #{@user.name} was successfully created.") }
format.json { render :json => @user,
:status => :created, :location => @user }
else
format.html { render :action => "new" }
format.json { render :json...
2012 Jun 09
7
ActiveRecord::AssociationTypeMismatch in UsersController#update
...:in `update''
app/controllers/users_controller.rb:66:in `update''
users_controller.rb
# PUT /users/1
# PUT /users/1.json
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to(users_url,
:notice => "The information for #{@user.first_name}
#{@user.last_name} was successfully updated.") }
format.json { head :no_content }
else
format.html { render :action => "edit" }
format.json { render :json => @user.errors,...
2006 Aug 17
0
redirect_to POST?
...Whenever a
user comes to my site, I''m automatically creating a user in the DB for
that person, however I''m also trying to stick to REST principles
otherwise. My idea was to have a before_filter :check_user that checked
to see whether this user existed or redirected to a POST users_url() to
automatically create the user, which would then redirect to a GET
user_url(:id => new_user_id).
Is there a way to redirect_to a POST, or should I forget about REST for
this circumstance and just do the user creation in the before_filter?
Thanks!
--
Posted via http://www.ruby-forum.co...
2007 May 24
0
Access named routes outside controller or view
...regular
class within a rails application.
I am working on a system to define menu structure with a rails app.
Rather than using something like :controller => user, :action => index
for each menu item, it would make things simpler if I could tap into the
named routes methods such as ''users_url'' as generated by map.resources
:users
I haven''t quite got enough knowledge of rails framework to work this one
out yet.
Thanks, Andrew.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are su...
2010 Nov 21
0
api respond_with json
...class with the following method that responds
to xml or json.
class UsersController < ApplicationController::Base
respond_to :html, :xml, :json
def index
respond_with(@users = User.all)
end
def create
@user = User.create(params[:user])
respond_with(@user, :location => users_url)
end
end
How do I call the create action from another app to interact with this
user controller class?
Is their any api package I use to do the call on create or something?
Thanks for any help.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscrib...
2008 Mar 24
2
link_to_remote and restful routes/urls
is there a way to access a restful resource with mike''s new
link_to_remote helper?
something like:
<%= link_to_remote h(user.name),
:update => "div_id",
:url => user_url(user) %>
of course, that doesn''t work.
i have also been trying things like:
:url => controller.asset_host +
2010 Jun 23
0
Rails 3 - AJAX Response
..."Failed to
change " + @user.name.titleize + "''s category" ) }
end
end
end
end
# DELETE /users/1
# DELETE /users/1.xml
def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to(users_url) }
format.xml { head :ok }
end
end
end
----
The Response:
====
Started POST "/users/1" for 127.0.0.1 at Tue Jun 22 23:31:07 -0400
2010
Processing by UsersController#update as JS
Parameters: {"commit"=>"Save", "authenticity_token"=>&...