Displaying 20 results from an estimated 100 matches similar to: "respond_with with templates and http status when creating an object"
2013 May 23
1
problem of respond_with working on nested resources
hi all:
when using namespace or nested resources in routes.rb,such as
"namespace :admin { resources :books }, we can use [:admin,@book] way to
generate path. It works fine in form_for , but when I use it with
respond_with in controller, I get problems.
The problem is when I put following code in controller:
def create
@book=Book.find(params[:id])
2011 Sep 09
0
respond_with and ajax
Suppose I have this controller:
class SalesController < ApplicationController
respond_to ?????
def get_price
@price = Product.find(params[:product_id]).price
respond_with ?????
end
end
1) What do I specify for respond_to() so that get_price() will accept
ajax requests?
2) What do I specify for respond_with() if all I want to do is return
@price?
--
Posted via
2010 Nov 21
0
api respond_with json
Hello,
So let say I created this 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
2010 Jun 27
0
[rspec-rails-2] conflict with view isolation and respond_with
Hey all,
For those of you interested in view isolation in controller specs, an issue has been reported with ActionController''s new respond_with method. Please take a look at http://github.com/rspec/rspec-rails/issues/103 and add comments if you have any thoughts on the matter.
Thanks,
David
2011 Jan 15
3
respond_with javascript
My ajax stopped working when I switched to using respond_with. For my
Votes, I have the create action and the corresponding create.js.erb,
and respond_to :html, :js, :xml in the controller. Heres the log when
I try and create a vote:
Started POST "/stories/3-asdfasdf1111/votes" for 127.0.0.1 at Fri Jan
14 20:46:36 -0800 2011
Processing by VotesController#create as */*
Parameters:
2011 Jan 11
9
Can I omit respond_with.
If I don''t want xml results but only html can I omit respond_with in
some actions?
For example index from:
respond_with(@sectors = Sector.all)
becomes only
@sectors = Sector.all
isn''t it?
--
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
2012 Sep 18
4
"best practices" for Rails serving RESTful JSON services for use by AngularJS, Ember.js, etc.
I''ve been writing a gem to implement and extend common controller
functionality so that Rails can be used with Javascript frameworks like
AngularJS (which we are using), Ember.js, etc. in such a way that the user
doesn''t have to tweak a a bunch of rails g controller boilerplate code to
provide services for use in these frameworks that in turn would require
various changes to
2009 Jun 06
2
How does controller call render when there's no render in action
Hello,
I was studying Rails source and at this point:
def process(request, response, method = :perform_action, *arguments)
#:nodoc:
response.request = request
initialize_template_class(response)
assign_shortcuts(request, response)
initialize_current_url
assign_names
log_processing
send(method, *arguments)
send_response
I have a
2008 May 24
1
link_to_remote, image_tag, mouseover is this possible?
Hi guys,
I was wondering if you are able to have a link_to_remote, having an
image_tag and the link_to_remote has a mouseover event that updates a
div. Does the image_tag need the mouseover event? I currently have:
<%= link_to_remote(image_tag(@p_image.public_filename(:thumb)), :update
=> "big_pic", :onmouseover => {:action => :color_change, :id =>
@p_image.id})%>
2010 Jul 27
13
3.0.0rc ActionController::RoutingError No route matches
Have been developing on 3.0.0beta4 and just updated to 3.0.0.rc.
When I try to link_to() a User object that previously had worked, I
get the following:
ActionView::Template::Error (No route matches
{:action=>"destroy", :controller=>"games", :id=>#<User ..... >
Yet I have in my routes.rb file has resources :users and my "rake
routes" shows:
2009 Dec 24
4
NoMethodError
Hi,
In a few words, can someone explain to me the NoMethodError. Googling
for answers will get you to something but a direct answer from experts
will give you something.
NoMethodError in Book#new
Showing app/views/book/new.html.erb where line #4 raised:
undefined method `title'' for #<Book id: nil, created_at: nil,
updated_at: nil>
Extracted source (around line #4):
1:
2013 Sep 26
2
Login Problem
Hello All,
I am getting a problem while login for inactive users.
While login I am getting -
Processing by Devise::SessionsController#new as HTML
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2
LIMIT 1
Redirected to http://localhost:3000/
Filter chain halted as :require_no_authentication rendered or redirected.
Inactive users
2013 Mar 24
5
Rails 4.0 has_many_through and fields_for
Hi all, I am trying to reproduce rails 3.2 behaviour with fields_for and
nested attributes.
class ControllerAction < ActiveRecord::Base
has_many :interactions, dependent: :destroy
has_many :roles, through: :interactions
scope :controllers, lambda {|name| where("controller_name_id = ?",
name)}
scope :actions, lambda {|name| where("action_name_id =
2010 Sep 05
0
Responding to a non-registered MIME type?
I''m trying to figure out how attachments are supposed to work with MIME
type-based responses. What makes attachments special is that in many
cases they are allowed to be arbitrary files. It would be too
restrictive to require that all possible types are registered
(Mime::Type.register).
Let''s say for GET requests on an attachment resource I want to return
metadata if the
2012 Mar 29
0
Arbitrarily nesting some attributes in rabl
Hi,
I''m designing a new API for my project, and I want to return objects
that have nested children as json. For that purpose i''ve decided to use
RABL.
I want the client side to be able to understand whether the object is
valid, and if not which fields are missing in order to save it
correctly.
The design I thought of should include some fields as optional, under an
optional
2006 May 14
1
[LLVMdev] Recharging the batteries
Hi,
I've noticed that http://llvm.org/status/ hasn't been updated for a while,
so
I tought that some of you might find the following information interesting
and/or encouraging...
For benchmarking the stuff I'm working on I needed to compile a number
of open-source packages. The settings I used:
AS=llvm-as
lLD=llvm-ld
AR=llvm-ar
CXX=llvm-g++
CC=llvm-gcc
CFLAGS="-g
2010 Jul 04
2
Rendering a different format in the implementation of a renderer
Yehuda has a nice article on implementing a custom renderer for PDF at
http://www.engineyard.com/blog/2010/render-options-in-rails-3/
I''ve tried to follow the example and I''m not sure I see how to get it to
work. If I understand things correctly, the format(s) usable in this
render call
respond_with(@resource) do |format|
format.xyz { render :xyz => ... }
end
2011 Sep 06
8
Ajax and rails 3 UJS (jquery)
Hi, guys,
I''m in the midst of moving an app from rails 2.3.8 to rails 3.0.9.
Sadly, rails 3 no longer has javascript generators and I''m now forced
to do more javascript.
For my project, I have selected jQuery as the javascript framework for
my rails 3.0.9 app.
What I have done to have my app''s deletion link (for each item)
trigger an alert box when the deletion
2012 Apr 05
5
rspec: identical tests fails when repeated
I''m doing RSpec controller testing with CanCan authorization, and I''m
seeing something I''ve never seen in RSpec before: the same test run
twice fails on the second one. I am NOT doing before(:all) or other
things that should cause state to persist between tests:
Here''s the relevant code:
context "POST create" do
context "with user logged
2011 Jul 11
2
Can't get this Rspec test to pass
Hello,
I''m completely new to Rspec testing and I''m finding it very difficult to
mock specific objects.
In this test, I have a before block setup as such:
[code]
before do
setup_controller_for_warden
controller.session[:operation_id] = 1
@operator = Factory :operator
sign_in :operator, @operator
@persist_herd = Herd.new