similar to: api respond_with json

Displaying 20 results from an estimated 20000 matches similar to: "api respond_with json"

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
2011 May 17
6
Nested Resource w/ Collection
Hi guys, In my routes file I have the following nested resource: resources :users do collection do get ''posts'' end end However, when I visit this URL: http://localhost:3000/users/posts, I get this error: "The action ''posts'' could not be found for UsersController" In my UsersController I have the following: class
2013 Feb 01
0
Add a customer renderer but I get missing template
Hi, I''m trying to include the support of Msgpack<https://github.com/msgpack/msgpack-ruby> in Rails 3.2 but when I try to return a mpac response, I get an error concerning a missing template. My renderer: Mime::Type.register ''application/x-mpac'', :mpac ActionController::Renderers.add :mpac do |mpac, options| self.content_type ||= Mime::MPAC
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
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 Jun 23
0
Rails 3 - AJAX Response
Hi, I need help with some AJAX in rails 3. So basically, I have a select option in my index page for my User model. This select option is a form that modifies the user''s type. The " :remote => true " works and the type is changed when hit the submit button. But, nothing happens in the browser. The user is updated. I''m actually not sure where to put either my JS /
2011 Feb 03
0
Correct way to exclude attributes from json serialization
Hi I''m using Mongoid and Rails 3, and I want to serialize one of my mongoid documents to json for publishing via a controller, e.g. class ReportController < ApplicationController respond_to :json def show report = Report.where(:report_id => params[:id]).first respond_with report end end This works ok, but pushes out every attribute on the document
2012 Jun 09
7
ActiveRecord::AssociationTypeMismatch in UsersController#update
Hi Im trying to link my User model to a Teams model. I seem to be getting the following errors. Any help would be great as Im just new to RoR Thanks error ActiveRecord::AssociationTypeMismatch in UsersController#update Team(#2183395560) expected, got String(#2174675960) app/controllers/users_controller.rb:67:in `update'' app/controllers/users_controller.rb:66:in `update''
2011 Jul 30
2
Get the current user as Json with Devise
Hi! I use Devise and Basic HTTP Authentication to access user areas from a mobile app. When the user enters its details in the app and it tries to "login" (you don''t actually login with basic auth as you send the credentials with each request) I want to get a response back with the user info, like user ID, email (not password) etc. - So, is there a way to do this out of
2010 Aug 28
0
Rails 3 rendering XML problem
I have Rails 3 application (running Rails RC1), and I have the following controller: class PluginsController < ApplicationController respond_to :html, :xml, :json def index @plugins = Plugin.all respond_with(@plugins) end end If I try to render http://localhost:3000/plugins it works fine, showing me the HTML version. If I try to get http://localhost:3000/plugins.json, it also
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:
2012 Sep 17
1
require current_password to update user information
Rails newbie here, I have been stuck on this for two days and can''t figure out why its not working. I want users to confirm/verify themselves by entering their current/old password before any information is updated. This is what My user_controller update action looks like I''m currently using rails 3.2 with the basic has_secured_password authentication that comes with it. def
2010 Jul 04
1
Rails 3: ActiveRecord .include not working
Really no idea what''s up... class Auction < ActiveRecord::Base has_and_belongs_to_many :categories end class Category < ActiveRecord::Base has_and_belongs_to_many :auctions default_scope order(''title'') scope :active, where(:active => true) end class CategoriesController < ApplicationController respond_to :html, :json # GET /categories/:id
2012 Feb 20
1
respond_to format.json not being called
Hi all, I''m submitting a form using jQuery, but in the respond_to block only the format.html action is called. This is the javascrip: send_button.on(''click'', function(){ var form = $(this).closest(''.modal'').find(''form''); $.post(''/messages'', form.serialize(), function(data, status, xhr){
2012 May 08
1
One to many relationships
I was trying to make one to many relationships - between professors controller to rate_professors controller and used scaffold. it''s giving me this error- NoMethodError in RateProfessorsController#index undefined method `rate_professors'' for nil:NilClass app/controllers/rate_professors_controller.rb:7:in `index'' Request Parameters:
2010 Jan 26
1
Why does UserSession.find return nil when using user_credentials = single_access_token?
I believe that I''ve set up everything such that single_access_token should be sufficient to pull a user''s session. The scenario is: Bob uses Firefox and creates an account on LoginUI (http:// www.coolaj86.info/loginui). Instead of using cookies, Bob''s single_access_token comes in the response to the request. LoginUI submits Bob''s single_access_token with every
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 Nov 02
1
getting devise to return json data when signing out
Hi all, In curl (the command line program), I can successfully log a user in using devise: def create respond_to do |format| format.json { if user_signed_in? return render :json => {:success => true, :errors => ["Already logged in."]} end resource = warden.authenticate!(:scope => resource_name, :recall =>
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
2009 Jan 11
2
Got an error on returning data as json format when the data is nil
Hi there, One of my app''s actions returns data as a json format. If the data exists, everything works perfect. But if the data is nil, I get the following error. -------------------------------- ActionView::MissingTemplate (Missing template user/show.erb in view path /var/www/my_app/releases/20090110234348/app/views:):