Jay Mark wrote:
> Priya Buvan wrote:
>> @books = Book.find(:all, :joins=>"books inner join authors as a on
>> books.title=a.name", :conditions => ['name LIKE ? ',
>> '%'+params[:author][:name]+'%'])
>>
>>
>>
Frederick Cheung wrote:
> On Dec 10, 5:36�am, Jay Mark <[EMAIL PROTECTED]> wrote:
>> Rails?
>> Is subselect not supported in Rails?
>>
>
> For the sake of argument you can do
>
> @books = Books.find_by_sql ["SELECT * FROM books WHERE title
Priya Buvan wrote:
> @books = Book.find(:all, :joins=>"books inner join authors as a on
> books.title=a.name", :conditions => ['name LIKE ? ',
> '%'+params[:author][:name]+'%'])
>
>
> try with the above code
I put the code in Authors Controller as it is, and I get nil object
error.
Since I
Ryan Bigg wrote:
> I have no clue. Author.find_by_name should be working when it
> (apparently) is not. Something is broken.
> -
> Ryan Bigg
> Freelancer
> http://frozenplague.net
I think so too. Thanks for your help.
Why is it so hard to find the correct syntax for doing a subselect in
Rail
Ryan Bigg wrote:
> And finally, what version of Rails?
> -
> Ryan Bigg
> Freelancer
> http://frozenplague.net
I am using 2.0.2 with mysql database
Cypray
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you ar
Jeff Cohen wrote:
> On Dec 9, 1:47�pm, Jay Mark <[EMAIL PROTECTED]> wrote:
>> Jeff Cohen wrote:
>> Thanks for all your help Jeff.
>> It is still not working.
>> The find_by_name, gives me this error:
>> "undefined method `find_by_name' for
Jeff Cohen wrote:
> On Dec 9, 11:52�am, Jay Mark <[EMAIL PROTECTED]> wrote:
>
>> where title is equal to the title returned by the inner query.
>> The strange thing here is, title has a unique entry in authors table,
>> but title has duplicate entries in the book t
Jeff Cohen wrote:
> On Dec 9, 11:06�am, Jay Mark <[EMAIL PROTECTED]> wrote:
>> @books = Books.find_by_sql ["SELECT * FROM books WHERE title IN SELECT
>> title FROM authors WHERE name = ?", params[:author][:name]]
>>
>> One problem is where to put the (
I have to use subselect for this query.
find_all_by_name and joins will not work.
Please I need help with getting the correct syntax for doing subselect
the rails way.
The query works fine in mysql.
I can't find the syntax in the docs or may be I was looking in the wrong
place.
My project is due t
Here is the result from ruby script/console
>> Author.new
=> #
>> Book.new
=> #
Ryan Bigg wrote:
> Ok... then you're on your own if you don't know how to type "ruby
> script/console" into a command prompt window and then type some more
> stuff
> -
> Ryan Bigg
> Freelancer
> http://frozen
I am using InstantRails. All I have is the command
The "Open Ruby Console Window" gives me the command window
Ryan Bigg wrote:
> I meant doing it in ruby script/console, not just in the command
> -
> Ryan Bigg
> Freelancer
> http://frozenplague.net
--
Posted via http://www.ruby-forum.com/
It says:
Author.new is not recognized as an internal or external command,
operable program or batch file.
same for Book.
Ryan Bigg wrote:
> And in the console do Author.new and Book.new and show me the output
> of each please.
> -
> Ryan Bigg
> Freelancer
> http://frozenplague.net
--
Po
Here are my models:
class Author < ActiveRecord::Base
belongs_to :book
end
class Book < ActiveRecord::Base
has_many :authors
end
Ryan Bigg wrote:
> pastie your models please
> -
> Ryan Bigg
> Freelancer
> http://frozenplague.net
--
Posted via http://www.ruby-forum.com/.
-
I am using find_by_sql because I get this error when I use find_by_name
or
find_all_by_name
"undefined method `find_by_name' for # Stop using find_by_sql!
>
> You can just do:
>
> author = Author.find_by_name(params[:author][:name])
> books = author.books.find(:all, :select => "title")
--
Po
Thanks guys, the first query is working fine now.
Rails is still rejecting the syntax of this subselect:
@books = Books.find_by_sql ["SELECT * FROM books WHERE title IN SELECT
title FROM authors WHERE name = ?", params[:author][:name]]
I know the inner select should be in (), but its not takin
an't find it in the Docs.
Please send me any pointers.
Thanks
Cypray
Frederick Cheung wrote:
> On Dec 8, 7:31�pm, Jay Mark <[EMAIL PROTECTED]> wrote:
>> Thanks for your help Fred. The wrong number of argument problem is gone.
>>
>> The queries are still not workin
ROM authors where name = ?", 'name')]
It is not accepting '(' or '[' to enclose the inner SELECT
I have tested this also in mysql and it works fine.
Does any one know the correct syntax for a subselect in Rails?
Thanks
Cypray.
Frederick Cheung wrote:
> On
I am using Rails 2.0.2 with mysql database
I am getting this error when running a query with Find_by_sql:
"wrong number of arguments (0 for 1)"
Here are my queries:
@authors = Author.find_by_sql["SELECT * FROM authors WHERE name = ?',
name"]
Also
@books = Books.find_by_sql["SELECT * FROM books
I think my problem is that Rails is not seeing the private method "def
author_age" that is holding the result of the query.
Do I suppose to put this in the Controller and not in the model?
How does the object @results get known to Rails?
Here is my code:
class Author < ActiveRecord::Base
has_
Well, I am having trouble with this query:
class Author < ActiveRecord::Base
has_many :books
def author_age
@results = Author.find :all, :conditions => ["age = ?",
params[:authors]]
end
end
I have this on view\authors\show.html
Author Name
Age
<% @results.each do |result|
I am using Rails 2.0.2 with mysql database
Migrate sets the primary key to id.
Is it possible to change it to another column?
If yes, how?
Thanks for your help
Cypray.
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message becau
The problem could be the query because when I search for one record, it
works.
So, this works fine without the query and the loop.
Author Name
Age
<%=h @author.name %>
<%=h @author.age %>
<% end %>
But this returns one 'Name' for the selected 'age'. That means it is
returning the
I made those changes, but I am still getting this error: "You have a nil
object when you didn't expect it!"
It is pointing to the line with the loop:
<% @results.each do |result|
My model look like this:
class Author < ActiveRecord::Base
has_many :books
def author_age
@results = Author.f
not sure if this is right!
<%=h @result.name %>
<%=h @result.age %>
What I want to do is to display the 'name' and 'age' that the query
returned.
Please help!
Cypray
Frederick Cheung wrote:
> On 4 Dec 2008, at 14:28, Jay Mark wrote:
>>
Thanks for the info guys. Now I am getting this error coming from the
author's model:
"syntax error, unexpected tASSOC, expecting ')'"
This is what I have in author's class
class Author < ActiveRecord::Base
has_many :books
def author_age
Author.find :all, (:conditions => ["age = ?", p
I am using Rails 2.0.2 with mysql
database
I have two tables: book and author
Table book has 3 columns: id, isbn, and title
Table author has 3 columns: id, name, and age
In the models I have:
class Book < ActiveRecord::Base
belongs_to :author
end
class Author < ActiveRecord::Base
has_many :b
Sazima,
You are so right Sazima. I am confused like a beginner. Thanks for
clearing that up for me. I have started learning Ruby. Thanks for all
the suggestions guys.
Jay.
Sazima wrote:
> Jay,
>
> You're confusing Rails with InstantRails. Rails is the web framework,
> Instant Rails is a pa
William, thanks for your help in resolving this issue.
It works great now. Thanks a lot.
Please, if you know any good book or online material
on Ruby/InstantRails 2.0.2, please post it in the Forum.
Thanks
Cypray
wfisk wrote:
> class Country
>
>
> def people_tribes
> peopl
I am new to Ruby/InstantRails. I am using InstantRails 2.0.2 with mysql
database
My application is named Area, it has two tables: people and country
Table people has two columns: name and tribe
Table country has two columns: location and population
In the models I have:
class People < ActiveReco
29 matches
Mail list logo