Colin,
Here's some of the debug trace...
=> 14 data = ActiveSupport::JSON.decode(request.body.read)
(rdb:1) p request.body.read
"loan=400"
So, this is consistent with the controller error..
JSON::ParserError: unexpected token at 'loan_request=400'
My functional testing approa
Dave,
Thanks for the consideration you show to this issue of mine, here is the
recap...
I have the following error from my Rails 3.1 controller...
JSON::ParserError: unexpected token at 'loan_request=400'
...where the controller code line in question is...
data = ActiveSupport::JSO
Hey,
Sorry to promote this again, but I'm stuck. Anybody?
Grar
--
Posted via http://www.ruby-forum.com/.
--
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@googlegroups.com.
To unsubs
Matt,
Thanks.
Continued work on this problem has shifted the emphasis, but I'm still
blocked and could use help.
I've changed the request from a GET to a POST, just to remove
uncertainty around the availability of the request.body for processing
in the controller.
I now have the following error
Hi,
I'm unable to properly test GET calls for my JSON API in Rails 3.1,
using ActionController::TestCase.
get :loan, ActiveSupport::JSON.encode(minimum_valid_json_params),
:format => :json
...where minimum_valid_json_params has the form...
{:one_thing=>"something", :another_thing=>23, ... }
..
Peter,
Wow, that's a lot!
One of my reasons for posting was I saw
ActiveModel::Serializers#from_json and I thought, 'What good is this, if
there is not some other facility to handle non-String attributes?' It
seems, though, that the functionality you have so generously sketched is
just not av
Hi,
I have non-ActiveRecord Ruby classes that I use for numerical (and
other) processing as part of an API service.
I seem to recall that AR will cast attributes, say, from a params hash,
into the data type expected for the attribute. That is useful, and I'm
missing that feature in my non-AR clas
Matt,
Thanks, that did the trick, and I think it unlikely that I would have
found that without some help!
Now, on to what is likely the subject of yet another post: How do I
obtain the effect of ActiveModel::Validations#validates_associated if
applied to non-ActiveRecord classes where I seek t
Frederick,
I seek to create Ruby modules that use ActiveModel::Validations. The
examples I have seen of ActiveModel::Validations all involve including
that module in classes. This is not what I want. I want to involve the
use of ActiveModel::Validations in a module, which I may then choose to
impl
Hey,
I'm trying to specify validations with ActiveModel::Validations at the
module level, i.e., I wish to mix-in validations to a module. I am not
succeeding at this, however. How do I mix-in ActiveModel::Validations
into another module and use its methods just as I would in a class?
Thanks,
L
OK, solved it.
Thanks to Luis's reference to the original rubygems guide, I was able to
build a simple gem that worked with my Rails 3.0.7 project. So, I
realized there was something wrong with my use of bundler in creating
gems.
The problem was that I was not managing the gem's development wi
Luis,
Yes, the gemspec is as listed in my previous post...
Thanks for the reference to RubyGems doc, which I am reading now, in
hopes of solving this.
Meanwhile, I'm wondering if there's interaction between rvm 1.9.2 and
this problem?
In this connection, I modified zipcode/config.rb as follows.
Hey,
Still no joy.
I thought I'd follow 7stud's example and recreate the gem structure to
see if I could load it after any reasonable modifications...
/lib
zipcode.rb -- require 'zipcode/config.rb'
/zipcode
version.rb
config.rb
cityandstate.rb
...where lib/zipcod
Hi,
I'm new to gem development. I just completed a gem for use with a Rails
3.0.7 project. The gem itself passes its tests. I've listed the gem in
the Rails project's Gemfile...
Unfortunately, Rails is choking on some requires in my gem. Here is what
I get in Rails:
activesupport-3.0.7/lib/activ
I can't recreate the problem, somehow, let's consider the question
dead until I can.
Thanks,
Grar
On Apr 26, 11:06 am, Marnen Laibow-Koser wrote:
> [Please quote when replying.]
>
> Grary Stimon wrote:
> > Marnen,
>
> > Here is the expression of a repr
5 am, Marnen Laibow-Koser wrote:
> Grary Stimon wrote:
> > Hi,
>
> > I'm new to nested resources. I'm surprised to find that to make my
> > code work I need to retrieve the parent model in my RESTful
> > controllers for my dependencies.
>
> > So, for exam
Hi,
I'm new to nested resources. I'm surprised to find that to make my
code work I need to retrieve the parent model in my RESTful
controllers for my dependencies.
So, for example, let's say A has_one B. In controller B I seem to need
to refer to parent A, for example:
@b = A.find(params[:a_id])
ill not be
persisted indefinitely -- indeed its creation should be silent to the
user.
Grar
On Apr 16, 2:07 pm, steve ross wrote:
> On Apr 15, 2010, at 2:37 PM, Grary wrote:
>
>
>
>
>
> > Hi,
>
> > Is there a compelling reason to prefer reliance on the params ha
Hi,
Is there a compelling reason to prefer reliance on the params hash vs.
the same info stored in a session hash? So, for example, params[:id] =
@loan vs. session[:loan_id] = @loan.id? It matters because I can make
prettier urls if I store certain uniquely identifying model attributes
as session
Hi,
In my RESTful controller's create method, how do I intercept and
modify any dependents before saving? That is, I have a model that is
the parent of nested associations gathered from a form. The first line
of this model's controller create method is:
@parent = Parent.new(params[:parent])
What
ur development database with
> "rake db:fixtures:load".
>
> Anthony Crumleyhttp://commonthread.com
>
> On Sat, Apr 10, 2010 at 8:59 AM, Grary wrote:
> > Hi,
>
> > I'd like to have the results of a migration file that prepopulates my
> > development da
response is that testing is typically performed on a limited
subset of development/production data that has been supplied from
fixtures. Can you please confirm?
Thanks,
Grar
On Apr 10, 9:52 am, Frederick Cheung
wrote:
> On Apr 10, 2:30 pm, Grary wrote:> Hi,
>
> > I'd like to h
Hi,
I'd like to have the results of a migration file that prepopulates my
development database available for testing. So, right now, after the
usual rake migration, I can access my prepopulated data via script/
console, but not in my unit tests. I've reviewed comments on this
subject but the custo
Hi,
I'd like to have the results of a migration file that prepopulates my
development database available for testing. So, right now, after the
usual rake migration, I can access my prepopulated data via script/
console, but not in my unit tests. I've reviewed comments on this
subject but the custo
Having duly considered it, I withdraw my suggestion of a 'tradeoff'.
I'm better off for your comments, so thanks all.
Grar
On Apr 5, 3:38 pm, Colin Law wrote:
> On 5 April 2010 19:48, Grary wrote:
>
> > Colin,
>
> > So, there is something I will regret eith
no previous experience in the matter, I'll adopt your proposal.
Thanks,
Grar
On Apr 5, 1:35 pm, Colin Law wrote:
> On 5 April 2010 17:57, Grary wrote:
>
> > What is the best practice for handling ActiveRecord attributes in
> > logic when those attributes were allow
What is the best practice for handling ActiveRecord attributes in
logic when those attributes were allowed to be nil? I've been handling
the possibly-nil status of my Numeric attributes in my logic by
calling to_f (to_i) on them, but I wonder if there's a better
practice? For example, default value
t; ActiveRecord::Base
> include MyEmailValidations
> end
>
> Does this solve your problem?
>
> /Lasse
>
> 2010/4/1 Grary
>
> > Hi,
>
> > Despite close reading of Matz's Ruby book and Agile Web Dev. w. Rails,
> > I can't figure out how to
Hi,
Despite close reading of Matz's Ruby book and Agile Web Dev. w. Rails,
I can't figure out how to tackle the challenge of sharing validation
code across models with attributes in common.
In each of my models I'd like to validate the shared attributes with a
custom validator that includes Rail
No takers, huh?
On Mar 22, 10:00 am, Grary wrote:
> Hi,
>
> Can anyone familiar with the use of factory_girl please comment on why
> I don't succeed with the following:
>
> has_one_instance = Factory.build(:has_one_class)
> assert_equal 10, has_one_instance.belon
Hi,
Can anyone familiar with the use of factory_girl please comment on why
I don't succeed with the following:
has_one_instance = Factory.build(:has_one_class)
assert_equal 10, has_one_instance.belongs_to_class.some_attribute
...when I've constructed the relevant factories, as follows:
Factory.
Fernando,
When you say...
"When you have too many migration files, simply remove them."
...I think this means that you refer to the schema as the one source
of summary information and that migration files are not informative
except when a developer wants to revert to an earlier stage via 'redo'
env, upgrade the prod env, and post-test the prod env, and when
> all is good, dump the db again as a post-upgrade backup. (I usually
> test each upgrade scripts against a similar version/state of the dev
> env prior to performing the upgrade on the prod env, and once the
> script
l side.
Thanks,
Grar
On Mar 19, 1:50 pm, Colin Law wrote:
> On 19 March 2010 16:07, Grary wrote:
>
> > Hi,
>
> > I prefer to keep one migration per model, but lately I'm adding data
> > that's expensive to drop every time I change my models.
>
> It is co
I've registered your skepticism.
Yes, I can't see that the benefit of satisfying my preference here
outweighs the burden.
That said, I still think it's a drag to sift through multiple
migration files.
Thanks,
Grar
On Mar 19, 12:40 pm, Ar Chron wrote:
> Grary wrote:
> &g
OK.
Also, I was just thinking: if I create models and then, without a
migration, create corresponding tables, I have sidestepped the
problem, such as it is.
Anyway, I've registered your skepticism.
Thanks,
Grar
On Mar 19, 12:40 pm, Ar Chron wrote:
> Grary wrote:
> > Hi,
>
Hi,
I prefer to keep one migration per model, but lately I'm adding data
that's expensive to drop every time I change my models.
How do I db:drop and db:migrate only selected tables/files? Basically,
I want to ignore certain tables and migrations altogether during
certain development phases.
Tha
Robert,
Another high quality response, thank you.
Let me respond briefly, selectively to your reply...
> - The parameters x, y & z will be initialized to known values.
> - The values of x, y & z are normally fixed, but can be altered by users
> (administrators) at runtime.
Yes, very infrequentl
...and see Ryan Bates' Railscast on prawn:
http://railscasts.com/episodes/153-pdfs-with-prawn
Grar
--
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-t...@googlegroups.com.
To unsubscribe fr
at my data should be accessible by administrators, but
what is the Rails mechanism for that access? Am I going to be issuing
raw SQL commands?
Thanks for any additional comment,
Grary
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk"
Hi,
In my Rails app, I have some parameters whose values change only
infrequently. These parameters are used in computations. Where is the
place for data like this -- data that is particular to the
application?
On the one hand, I might think a flat file (yaml) is appropriate, but
maybe I shouldn'
rent model for later
recovery?
I would have guessed it was something like as follows:
class ChildController...
def create
@parent = ParentModel.find(params[:id]) # How to get "current"
parent from database?
@parent.child = ChildModel.new(params[:child])
...
Any thoughts?
Gra
Hi,
I'd like to conserve the sum total of several text fields on my form,
even as I set them to blank upon a user link action.
The following in-line snippet fails to store the value of my sum total
field locally for eventual reassignment. (I am re-assigning it because
the fields all have an obser
nk_to_function(name, h("add_fields(this, \"#{association}\",
\"#{escape_javascript(fields)}\")"))
end
What I think I need to do is figure out how to append to some
arbitrary place on the DOM, like the passed-in link element. I just
don't know how.
Thanks for any help,
Gra
Hi,
I'd like to render the results from show, create, edit and delete
actions for several different models (one controller per model) on one
page.
While these several models are conceptually related, they do not need
to be associated with each other. So, I'd rather not impose
associations on them
@Robert - Yes, I read that portion of the documentation and thanks for
the reminder.
Otherwise, of potential interest to discussants...
I now have a migration adding a unique index to a model, like so:
add_index :projects, [:name, :street_address, :city, :state, :zip],
:uni
Another fine idea, it would appear. But why do both? Does checking a
combined parameters column before validation save me some kind of
performance hit?
Grar
On Feb 23, 11:17 am, Michael Pavling wrote:
> On 23 February 2010 01:30, Rick DeNatale wrote:
>
> > To create an index you can create a mi
Rick,
Thanks. That sounds exactly like what I'm after...
Grary
On Feb 22, 8:30 pm, Rick DeNatale wrote:
> On Mon, Feb 22, 2010 at 4:54 PM,Grary wrote:
> > Thanks Fred.
>
> > What do you mean by 'use a unique index'?
>
> > What I am concerned about
Thanks Fred.
What do you mean by 'use a unique index'?
What I am concerned about is logical uniqueness, i.e., persist only
data objects with a unique combination of attributes.
Thanks,
Grar
On Feb 22, 3:54 pm, Frederick Cheung
wrote:
> On Feb 22, 8:52 pm, Grary wrote:
>
>
Hi,
>From a model class, what is the standard way of ensuring uniqueness
across multiple columns (attributes) simultaneously?
In other words, I want to ensure only unique "rows" are persisted to
storage. I feel like there must be a straightforward way to do this.
Any suggestions?
Thanks,
Grar
n Feb 17, 10:48 am, Frederick Cheung
wrote:
> On Feb 17, 1:59 pm, Grary wrote:
>
> > Fred,
>
> > I'm just hoping to get Rails working again, so I'll do whatever's
> > easy...
>
> > sudo gem install rubygems-update
> > sudo update_ruby
Fred,
I'm just hoping to get Rails working again, so I'll do whatever's
easy...
sudo gem install rubygems-update
sudo update_rubygems
...I still get the same message.
What did you mean when you wrote: "Sounds like you need to install
rubygems for your new
ruby install"?
Thanks,
Grar
--
Yo
Fred,
Per your comment...
"...if your PATH has /opt/local/bin higher up then the /opt/local
install of ruby might not have
rubygems at all. Sounds like you need to install rubygems for your new
ruby install"
...yes, here is my path:
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/
ings in RubyGems?
Thanks for any help,
Grary
--
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-t...@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-talk+unsub
54 matches
Mail list logo