That did the trick! Thanks!
But, I am sorry I did not get your explanation. Forgive me, I am very
new to Ruby and Rails. Could you please explain why it didn't work
before, and why it worked your way?
On Aug 27, 7:47 am, Frederick Cheung frederick.che...@gmail.com
wrote:
On Aug 27, 8:35 am,
Also, in my controller, I'd like to call the parent controller's
method to format my json in a certain way...So instead of this:
respond_to do |format|
format.json { render :json = @projects.to_json(:include =
[:apps]) }
end
I'd like to do something like this:
result = nested data
respond_to
On Aug 27, 8:35 am, John Doe john.doe.hello.wo...@gmail.com wrote:
In my projects controller, I am trying to do this:
@projects = Project.find(:all, :include = [:books])
My hope is to get a nested data structure back that looks something
like:
Well you what you get back is an array of
On 9 July 2010 03:08, RailsFan Radha li...@ruby-forum.com wrote:
I come from a db world.
Can someone interpret this please, self.questions.reject{|q|
q.nil?}.all
this explains what .reject does:
http://ruby-doc.org/core/classes/Enumerable.html#M003126
So essentially, the line takes the
On Jul 9, 8:44 am, Michael Pavling pavl...@gmail.com wrote:
On 9 July 2010 03:08, RailsFan Radha li...@ruby-forum.com wrote:
I come from a db world.
Can someone interpret this please, self.questions.reject{|q|
q.nil?}.all
this explains what .reject
On Fri, Jul 9, 2010 at 05:28, Frederick Cheung
frederick.che...@gmail.com wrote:
For what it's worth, reject{|q| q.nil?} is the same as compact
... if the collection is an Array. Without more context, I don't know
if that's so. The compact method is on that, not Enumerable.
-Dave
--
I come from a db world.
Can someone interpret this please, self.questions.reject{|q|
q.nil?}.all
I'm overwhelmed by the syntax in the second line,
self.questions.reject{|q| q.nil?}.all
def needed_questions
self.questions.reject{|q| q.nil?}.all
end
something like that.
i can somewhat
RailsFan Radha wrote:
I come from a db world.
Can someone interpret this please, self.questions.reject{|q|
q.nil?}.all
I'm overwhelmed by the syntax in the second line,
self.questions.reject{|q| q.nil?}.all
Go look up the relevant functions (especially reject) in the
documentation.
If your models are set up correctly you can do '@user.questions' for
the collection. You can set up a method or named_scope maybe on the
user model:
def needed_questions
self.questions.reject{|q| q.nil?}.all
end
something like that.
On Jul 1, 9:37 pm, RailsFan Radha li...@ruby-forum.com
You could either use the find_by_sql method or the :joins method. (As
someone has stated earlier that avoid find_by_sql for performance and
maintanence reasons)
sample sql to put in find_by_sql in your model
select question_id from responses r1
where not exists
(select question_id from
On Sep 7, 1:52 am, Phlip [EMAIL PROTECTED] wrote:
Appointment.find( :all, :include = :tasks,
:conditions = { :'tasks.project_id' = 1} )
In summary, provide enough :has_many = :through to get to the keying table,
then put it into your :include and :conditions.
Mark Studebaker wrote:
I'm not quite sure how to get at this data using Actrive record.. I'm
trying to get all the appointments made for a particular project. I'm
using four models, Projects, Tasks, Resources and Appointments.
The SQL gets me what I'm looking for but how do I do it
Mark Studebaker wrote:
What I was trying to do was something like this project.appointments to
display all the appointments for a specific project.
Briefly, since you seem to have more experience with raw SQL than ActiveRecord
(better than the other way around!;), try inspect_sql to see
13 matches
Mail list logo