Displaying 20 results from an estimated 2000 matches similar to: "Different behaviour on ActiveResorce with JSON or XML"
2008 Dec 02
2
ActiveResource - xml and json format return different results
Hi,
I''m using Rails 2.1.2. and I wanted to switch ActiveResource format to
JSON and thought that it will work smoothly, but unfortunately it
wasn''t the case.
XML and JSON formats generate different objects:
XML version
#<User:0xb7658440 @prefix_options={}, @attributes={"created_at"=>Mon
Nov 28 11...}>
JSON version
#<User:0xb746af5c @prefix_options={},
2012 Feb 26
0
Getting ArgumentError calling initialize with ActiveResource 3.2.1
instantiate_record calls new, and new implicitly calls initialize
(unless I''m not understanding the mystery)
In base.rb
def instantiate_record(record, prefix_options = {})
new(record, true).tap do |resource|
resource.prefix_options = prefix_options
end
end
As it''s written get an ArgumentError as this calls new(record, true).
If I change the code in base.rb to the
2007 May 14
6
ActiveResource and RESful edit
Hi
I''d like to know how to have ActiveResource generate a URL for the
/teams/1/edit
type of resource.
I''ve got custom_methods.rb and have used
Team.find(1).get(:edit)
This generates
http://localhost:xxxx/teams/1/edit.xml
But all I get returned is a hash of the attributes (in this case of
team 1), rather than an object of team 1.
In other words the
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
2007 Jan 05
0
ActiveResource cache using memcache-client
I''ve created this class that overrides methods for
find,delete,destroy,reload, and save in activeresource. The code
populates a local memcache daemon and uses that cache for future find
requests. I''m posting it here to get whatever feedback people have.
I''m most interested in the pro/con of inheritance over a mixin and how
such a module might be tested.
$ cat
2010 Jul 05
0
Serialized JSON object importation
Hi,
I would like to import a serialized object (from a JSON export) inside
my database.
It work fine if for instance I do:
>> l = Yea.create(:title => "foo bar")
=> #<Yea id: 3, title: "foo bar", created_at: "2010-07-05 21:44:54",
updated_at: "2010-07-05 21:44:54">
>> j = l.to_json
=>
2008 Jan 02
0
Re: RubyOnRails build 8525 failed
Fix for the bad (failing) test here: http://dev.rubyonrails.org/ticket/10664
On Jan 2, 5:33 pm, alexey.verkhov...@gmail.com wrote:
> The build failed.
>
> CHANGES
> -------
> Revision 8522 committed by bitsweat on 2008-01-02 09:03:56
> db:sessions:clear task uses session_table_name method. Closes #10631 [Cheah Chu Yeow]
>
> M /trunk/railties/lib/tasks/databases.rake
>
2010 May 11
1
has_one/belongs_to -- accessing the subordinate
With a has_one/belongs_to relationship, what''s the best way to guarantee
that the belongs_to object gets created and is accessible alongside the
has_one object? I *think* the after_create callback is a good choice,
but I discovered an oddity while trying it.
F''rinstance, if every horse has a carriage:
============
ActiveRecord::Schema.define do
create_table(:horses) {|t|
2008 Jan 12
1
Collection_Select not showing Selected option
Hi, I''m having some problem with getting collection_select to return
the current value when editing a record. According to everything I''ve
seen, there was an issue but it''s been fixed, but I can''t figure out
why it isn''t returning the current value as a selected option. I''ve
checked the table structures, and both the call_driver.product_line_id
2011 Apr 27
2
Can not create model instance via params on specific model but can on others....
Anyone have an idea on this? Got a weird situation where on a specific model
I can not create an instance using params, yet it works fine on other
models. The model which does not work is a stock model, there is no logic in
it. Ruby 1.8.7/Rails 3.0.5.
Does not work:
(rdb:1) PaymentTransaction.create(:purchase_id => 3)
#<PaymentTransaction id: 2, purchase_id: nil, action: nil, amount: nil,
2006 Mar 24
1
Multiple table relationships
Hello,
I''m just starting out with some Rails development and have the following
table structure. I understand how to do a two table has many join but I
actually need to relate a third table. Here is my structure:
components
id
name
updated_at
elements
id
name
updated_at
element_types
id
name
updated_at
components_elements
component_id
element_id
2008 Oct 06
1
Rails console, saving objects
I was reading a book and following the instructions in it.
>> class Story < ActiveRecord::Base; end
=> nil
>> story = Story.new
=> #<Story id: nil, name: nil, url: nil, created_at: nil,
updated_at: nil>
>> story.class
=> Story(id: integer, name: string, link: string,
created_at: datetime, updated_at: datetime)
I do not remember me asking for id, name, link or
2009 Apr 15
2
Getting Started with Rails - post_comment_url
Hi,
Thanks for a wonderful Getting Started with Rails. I am up to the last
section and just added the comments part.
So while testing and looking over comments_controller.rb;
I see the reference to post_comment_url calll where is this defined.
Below is the message I am getting.
Thanks
ActionController::RoutingError (post_comment_url failed to generate
from {:post_id=>#<Post id: 1, name:
2007 Nov 14
1
has_many_polymorphs and acts_as_list ?
First, BRAVO for this wonderful plugin: has_many_polymorphs ! Now my
problem:
4 models : Collection, Page, Fragment, Belonging (which is the join
table):
1 class Collection <
ActiveRecord::Base
2 has_many_polymorphs :elements,
3 :through => :belongings,
4 :from => [:pages, :fragments, :collections],
5 :as => :collector,
6 :parent_order =>
2010 Jul 20
4
MySQL index question
I am trying to speed up some DB operations and perhaps have gone overboard
with indexes. Does MySQL usually use only one index per query and simply
match keys on the results of the indexed first part? For example:
DELETE FROM tokens WHERE 6813946236211560448 <= fnv AND fnv < 6818449835838930944 AND updated_at<''2010-06-20 14:08:55'' AND occurrences=0;
If I understand
2013 Sep 11
1
when does 'updated_at' column get updated?
Using centos 6 with puppet-2.6.17 with thin_storeconfigs with mysql and
nagios exported resources. Every time an agent connects to the master, the
updated_at column in the hosts table is updated. However, the updated_at
column in the other tables is not updated even when I alter a nagios
resource attribute like retry_check_interval. What are the conditions by
which the updated_at column is
2006 Jul 11
8
Stop updated_at from auto updating?
Hi
Is there any way to temporarily stop the updated_at field from being
updated when a record is modified with ActiveRecord?
I have a date field which is keeping track of when the record data was
last checked by my application and my app manually updates it, of course
when I do this the updated_at field is also touched making it fairly
useless for finding out when the actual data was changed
2010 Dec 31
9
Headers in ActiveResource
I am creating a rails app that is a gui wraping a restful web service
that uses a websso for authentication. This websso sets a series of
headers that I need to pass from the request to the
ActiveResource.find methods. As this is stuff like username etc it is
going to be different for each request. I can find examples on how to
set headers for all requests not just one.
Does anyone know of a way
2009 Nov 27
2
update_attribute does not update
My server is running Rails 2.3.4...am I not doing this correctly or is
something borked?
>> c=Contact.last
=> #<Contact id: 24, name: "Larry", email: "larry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", phone:
2147483647, account_id: 8, created_at: "2009-11-27 18:16:25",
updated_at: "2009-11-27 18:40:08", hide_name: false, hide_phone:
false,
2006 Apr 22
1
Newbie question about using helpers in controllers
I''m trying to display a list of pages in xml. I want to change
page.update_at to distance_of_time_in_words_to_now. However whenever I
run it I get an error saying:
undefined method `distance_of_time_in_words_to_now''
I know I can just go the rails api and copy the source, but there must
be another way.
def list
@page = Page.find(:all, :order => "updated_at desc")