Displaying 20 results from an estimated 70000 matches similar to: "Why is include_root_in_json true now"
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
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:
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){
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 Apr 17
0
newbie: to_json only/except + association confusion
hi,
i want to return to_json with ''only'' and also filtered.so i tried
various ways, but none of them are really good:
A)#OK , but filter missing
format.json { render :json => @project.to_json(:only =>
[:title ], :include=> { :tasks => {:only=>[:id,:title] } } ) }
B)#Not OK > filter does not work,
format.json { render :json => @project.to_json(:only
2011 Feb 15
7
Hide/Show Div and link_to_remote
Hi
I want to show some info and provided an ''edit'' button next to it.
This will change the display info to an editable form.
I''ve seen this done before, but what I can''t figure out is whether I
have to use an actual remote action to the rails server?
I think I should be able to render both the edit box and the display
info as seperate divs, and then show/hide
2012 Sep 22
1
formtastic does not save at all
Rails 3.1.3
I am using Formtastic gem in order to deal with multi-select
dependencies.
<%= semantic_form_for(@give) do |f| %>
<%= f.inputs do %>
<%= f.input :departure,
:collection => Departure.find(:all, :order=>:city).collect{ |c|
[c.city,c.id]},
:required=>true %>
<div id="destinationCity">
<%= render :partial =>
2013 Apr 02
4
gmaps4rails: undefined method `model_name' for NilClass:Class
Hi All,
just in a spot of bother with this gem, I am trying to create a new
location and get the above msg.
here is my controller:
class LocationsController < ApplicationController
# GET /locations
# GET /locations.json
def index
@locations = Location.all
@json = Location.all.to_gmaps4rails
end
respond_to do |format|
format.html # index.html.erb
2011 Nov 29
1
ajax question
Hello,
could you please explain what''s wrong with this code:
Rails 3.1.1
skills_controller.rb
class SkillsController < ApplicationController
# GET /skills
# GET /skills.json
def index
@skills = Skill.all
respond_to do |format|
format.html # index.html.erb
#format.json { render json: @skills }
format.js
end
end
end
index.html.erb
<%=
2012 May 21
4
Rendering partial views with ajax calls in rails 3.1
I''m starting now with rails, and i have simply question i think.
I need to render two partials in one ajax call:
I have the following controller:
# GET /hosts/1
# GET /hosts/1.json
def show
@host = Host.find(params[:id])
respond_to do |format|
format.html #show.html
format.js
format.json { render :json => @host }
end
2010 Dec 22
2
Rails - JSON object with an array?
Hello, I''m able to create and send a JSON object like so:
@mylist << {
:id => item.id,
:name => name.id
}
render :json => { :result => ''success'', :mylist => @mylist }
That works great. Problem I''m having now is that I need to include
users which can be 1 or users per item.
@mylist << {
2011 Jul 14
1
rails 3.0.9 ArgumentError (redundant UTF-8 sequence):
Hi guys,
I have a simple controller
def gmap
@intentsearches = Intentsearch.all
logger.info @intentsearches
respond_to do |format|
format.html {render :gmap}
format.xml {render :xml => @intentsearches }
format.json { render :json => @intentsearches }
end
end
and want a json response, but i do get the following error
Completed 500 Internal
2012 Mar 06
0
Devise/Cancan Signout User On Controller Action
I have implemented Devise for Authentication and Authorization in ROR
application everything seems fine but getting one issue. I have two
modals "Account" and "Transactiona" , and so two controllers
respectively.
My Transaction Index view call one of Account Controller method like
this
2010 Oct 31
0
Error in rendering json
Hello,
in my controller I use following code to render json.
render :json => @product, :callback => params[:callback]
I would expect (for example) following to be rendered:
callback({"name":"Computer","price":500})
Instead, it renders:
callback([{"name":"Computer","price":500}])
Notice the square brackets which disables
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
2013 Sep 19
0
CRUD model in a bootstrap modal with jquery, ajax - best practice
Hi,
i have an model, which i want to show edit and update in a dialog via ajax.
What i do at the moment:
To open the Modal and render the partial, i send an ajax request to
controller#show with ujs
this is the link:
<a class="person-dialog" data-remote="true" data-type="script"
href="/en/people/32" onclick="return false">Fidel
2013 Mar 11
8
Access instance variable in ajax rendered by controller - Rails
I am making an ajax call to my controller. Controller is sending in the
response in an instance variable(as a json object). How can I access the
same in my ajax javascript?
This is my ajax call code:
$(document).ready(function(){
var currentCellText;
$(".inline").click(function() {
currentCellText = $(this).text();
$.ajax({
type: ''GET'',
dataType: "json",
2012 Mar 26
3
render :json not sending any data back ...
[rails 3.2.2]
I perform an ajax call :
...
$.ajax
url: " /backoffice/expenses/rate"
type: "GET"
dataType: "json"
data:
project_id: $(''#project_id'').val()
code: $(this).val()
success: (result) ->
alert result
$(''#expense_price'').val(result)
in
2011 Oct 25
7
additional model attributes
Hi,
i have a "place" model with 2 columns (id, name).
I''m calling an external api which gives me data to create a new place
object.
I would like to add the address from the external place to the place
object and render it as a json result, without storing it in the
database.
i don''t get any errors, but the address never shows up within the json
output. i''ve
2010 Mar 23
7
redirection in format.json ...
I have presently a render :json which modify the current page
if @request.save
format.html { redirect_to(@request) }
format.json { render :json => { :result => ''success'', :request
=> request_path(@request) } }
....
but I would like rather to redirect to an index page
I wrote this but it doesn''t redirect ...
format.json {