Cooler
This page is for random comments, discussion, etc.
Questions for the Dec. 17 Panel go here: http://e168f08.plugh.org/cooler/panel-of-rubyrails-professionals-dec-17/ (same password as for downloads)
This page is for random comments, discussion, etc.
Questions for the Dec. 17 Panel go here: http://e168f08.plugh.org/cooler/panel-of-rubyrails-professionals-dec-17/ (same password as for downloads)
Add New Comment
Viewing 129 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Quick comment on setting up the external site. My Ubuntu server on slice did not come with 'make'. I used "sudo apt-get install build-essential" to install the gnu compiler, after which all worked well.
I may have missed a step in the tutorial. Perhaps this will help a classmate.
Take care,
Mike
Do you already have an account? Log in and claim this comment.
Googling now.
Mike
Do you already have an account? Log in and claim this comment.
Mike
Do you already have an account? Log in and claim this comment.
My Sequence form is the most complicated. In a single region I need to have:
one form that just wants to collect preferences (pose type and pose subtype) so the app can narrow what's listed in the next section. If the user selects either type or subtype the next section will list only the poses that are children of that type/subtype. If the user selects both type & subtype the list will include only poses in both sets (overlapping). I want to do something like <% form_tag {:action =>"accept_asana_categories_and_return_asanas", :id => @asana_type } do %>.. but instead of choosing just @asana_type I want to return either/both asana_type and asana_subtype as parameters to "accept_asana_categories_and_return_asanas".
Any ideas as to how to accomplish that?
The next form needs to list a collection of asanas based on the first form's returned parameters, types/subtypes; each pose is a link that will create a new row in the join table, asanas_sequences. Ultimately when Ajax comes in (I haven't even been able to think about Ajax yet!) the list of poses will update automatically.
Do you already have an account? Log in and claim this comment.
Then it might be a lot simpler.
Do you already have an account? Log in and claim this comment.
If we have the following model:
class User < ActiveRecord::Base
belongs_to :clinic
we can say things like:
validates_presence_of :clinic
but we can't say:
validates_uniqueness_of :login, :scope => :clinic
instead we have to say
validates_uniqueness_of :login, :scope => :clinic_id
since the "belongs_to :clinic" in the migration for the user model creates a column called "clinic_id" not "clinic".
This seemed very counter-intuitive, and took me a number of hours to debug so I thought I would post for others.
Do you already have an account? Log in and claim this comment.
I.e., 'john' for clinic #1, 'john' for clinic #2.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
map.resources :sequences
map.resources :sequences, :member => { :get_postures => :get }
map.resources :sequences, :has_many=>:user_observations
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
How can I add a standalone class to RoR ? I have some source code which I wrote, it works perfectly as a script, there is a class called "IMDB" which, you guessed it, scrapes IMDB for content. I run it from the command line or with a wrapper, but want to get it into my rails site. Where do the files go, and how do you "require" them in the right place?
(I'm a C++ developer and can't believe that ruby would have an obvious solution to this too)
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Sequence: has_many :somethings
Sequence: has_many :asanas, :through :somethings
That kind of thing.
Do you already have an account? Log in and claim this comment.
AsanasSequences is the join table. I implemented acts_as_list so that users could rearrange the order of postures in their sequences. The actual name of the association I want to validate in Sequence.rb is "postures", and each of these is an instance of AsanasSequences that relates to one of the asanas.
To access the properties of an asana in a Sequence named sequence1 you need to use sequence1.posture.asana.
Here is the class def for Sequence:
class Sequence < ActiveRecord::Base
belongs_to :user
has_many :postures, :class_name => "AsanasSequences", :order => :position
has_many :asanas, :through => :asanas_sequences
end
thanks!
catherine
Do you already have an account? Log in and claim this comment.
class Sequence . . .
has_many :postures, :class_name => 'AsanasSequences', :order => :position
has_many :asanas, :through :postures
The value of :through is the name of the ASSOCIATION through which you have many. So here it should be :postures. Maybe it works with :asanas_sequences.
Now that I see this model: Are you sure you want to disallow a Sequence with no asanas? Why?
Suppose in my UI I want to create a sequence named "foobar" and then add a bunch of postures -- Right after I create the sequence there would be no associated postures. So it seems to me that it would not be wrong ot allow the collection to be empty.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
E.g., if a Book belongs_to :user , you would check user_id to be non-null. You can also set that in the migration so AR will enforce it there.
Do you already have an account? Log in and claim this comment.
I'm working on some test capabilities for the final project. I want to be able to run a server which will inject messages using HTTP to my WEBrick web service.
I've created a script which will do this. I can make it run as long as I do not attempt to access any User Defined Classes, for example Classes in my app/models directory.
I've tried to include the environment by using:
require File.dirname(__FILE__) + '/../config/boot'
which is apparently how the script/console and other scripts pull in the Environment variables. The script does not recognize my model classes. If I require them in my script explicitly, I can see them, but if they refer to additional classes (maintained in the lib library), Ruby complains about not being able to find them.
Is there any way to make this work? Please let me know if you need me to provide more information.
Mike
Do you already have an account? Log in and claim this comment.
http://localhost:3000/users/1
and the like?