Ruby on Rails Tuesday, July 31, 2012

On 1 August 2012 06:04, John Blaze <lists@ruby-forum.com> wrote:
> Hi,
>
> I am new to RoR and have been pulling my hair out trying to figure out
> associations.
>
> Lets say I have 2 tables: vehicles and vehicle_types. ONE vehicle HAS
> ONE vehicle_type. Therefore, in my opinion, vehicle_type belongs_to
> vehicle.

No, the names of associations are confusing at times. In your case a
vehicle type can be associated with many vehicles, therefore
vehicle_type has_many vehicles. A vehicle is only of one type, so
vehicle belongs_to vehicle_type, and it is the vehicle that has the
vehicle_type_id.

Colin

>
> Hence, vehicle_types will contain the vehicle foreign key. To me this is
> already weird. I would like vehicle_types to be a table containing a
> column that lists types of vehicles- "truck", "car", "bus", etc. It does
> not need to know what vehicle is associated with it. The vehicles table
> needs to know what vehicle_type it is.
>
> I would like to use the vehicle_types table to populate a Select Menu on
> a form. If I create the associations as suggested by RoR, with the
> foreign key going on the belongs_to table (vehicle_types), the Select
> Menu would be populated with duplicate vehicle_types. EG:
>
> vehicle_id vehicle_type_id type
> 1 1 car
> 2 2 truck
> 3 3 car
>
> Does this make sense?
>
> Like I said I have spent days reading over the associations again and
> again but I just can't figure it out. Any help would be greatly
> appreciated.
>
> Thanks.
>
> --
> 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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

Does anyone got it working for Rails 3

On Sunday, 6 September 2009 18:58:19 UTC+5:30, Mark Studebaker wrote:

Have you tried has_many_polymorphs (2.13)




From: Heinz Strunk <rails-mailing-list@andreas-s.net>
To: rubyonrails-talk@googlegroups.com
Sent: Sunday, September 6, 2009 4:47:51 AM
Subject: [Rails] Re: Polymorphic many-to-many relationship?


Managed to get it working by changing the fixture to:
resource: <%= Fixtures.identify(:row_house) %>
resource_type: BuildingType

Still don't like it cause that's not what RoR is about. Any help would
be still highly appreciated :)
--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/8IYKjZGSztoJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

Hi,

I am new to RoR and have been pulling my hair out trying to figure out
associations.

Lets say I have 2 tables: vehicles and vehicle_types. ONE vehicle HAS
ONE vehicle_type. Therefore, in my opinion, vehicle_type belongs_to
vehicle.

Hence, vehicle_types will contain the vehicle foreign key. To me this is
already weird. I would like vehicle_types to be a table containing a
column that lists types of vehicles- "truck", "car", "bus", etc. It does
not need to know what vehicle is associated with it. The vehicles table
needs to know what vehicle_type it is.

I would like to use the vehicle_types table to populate a Select Menu on
a form. If I create the associations as suggested by RoR, with the
foreign key going on the belongs_to table (vehicle_types), the Select
Menu would be populated with duplicate vehicle_types. EG:

vehicle_id vehicle_type_id type
1 1 car
2 2 truck
3 3 car

Does this make sense?

Like I said I have spent days reading over the associations again and
again but I just can't figure it out. Any help would be greatly
appreciated.

Thanks.

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

I need to rephrase this.

Here's the code:


class Project < ActiveRecord::Base
has_many :tasks
accepts_nested_attributes_for :tasks
end

class Task < ActiveRecord::Base
belongs_to :project

validates_presence_of :project_id
validates_associated :project
end

Project.create!(
:name => 'Something',
:task_attributes => [ { :name => '123' }, { :name => '456' } ]
)

The pattern of this is:
* Validate Project
* Validate Tasks
* Save Project
* Save Tasks

The book says:
"if you want to make sure that the association is valid on a
belongs_to, you have to use validates_associated in conjunction with
validates_presence_of". And that is what the above code does.

But the problem with the above technique is that when we call create!
on the project, it validates the project (and between :validate =>
true default on project an the validates_associated call on the
belongs_to, these two calls prompt to check if the association are
valid next), and since the project has not yet been saved, this will
raise an error, because project_id does not exist yet, since the
project has not been saved yet. So why does book say to use "
validates_presence_of :project_id"?


On Jul 31, 11:57 pm, John Merlino <stoici...@aol.com> wrote:
> In a popular Rails book:
>
> http://books.google.com/books?id=slwLAqkT_Y0C&pg=PT366&lpg=PT366&dq=%...
>
> it states that if want to make sure that the association is valid on a
> belongs_to, that is, make sure the parent is valid, then you use
> validates_associated in conjunction with validates_presence_of:
>
> class Project < ActiveRecord::Base
>   has_many :tasks
>   accepts_nested_attributes_for :tasks
> end
>
> class Task < ActiveRecord::Base
>   belongs_to :project
>
>   validates_presence_of :project_id
>   validates_associated :project
> end
>
> Unfortunately, this raises an issue because if the project validation
> fails, then it won't have an id, and then when Rails goes to validate
> the tasks, the task in turn will fail validation because they won't
> have a project_id. So why would the book suggest this? Or is it the
> accepts_nested_attributes_for that is causing the above behavior?
>
> thanks for response

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

In a popular Rails book:

http://books.google.com/books?id=slwLAqkT_Y0C&pg=PT366&lpg=PT366&dq=%22validates_associated+in+conjunction+with+validates_presence_of%22&source=bl&ots=9bZwHNjzvG&sig=aTN0WnknjzZ0WfRd9PeJGxQSAEU&hl=en&sa=X&ei=RagYUM_zH4T89gTW_YDwCw&ved=0CC8Q6AEwAA#v=onepage&q=%22validates_associated%20in%20conjunction%20with%20validates_presence_of%22&f=false

it states that if want to make sure that the association is valid on a
belongs_to, that is, make sure the parent is valid, then you use
validates_associated in conjunction with validates_presence_of:

class Project < ActiveRecord::Base
has_many :tasks
accepts_nested_attributes_for :tasks
end

class Task < ActiveRecord::Base
belongs_to :project

validates_presence_of :project_id
validates_associated :project
end


Unfortunately, this raises an issue because if the project validation
fails, then it won't have an id, and then when Rails goes to validate
the tasks, the task in turn will fail validation because they won't
have a project_id. So why would the book suggest this? Or is it the
accepts_nested_attributes_for that is causing the above behavior?

thanks for response

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

I am trying to install redmine on my Centos 5.8 box per
http://www.redmine.org/projects/redmine/wiki/HowTo_install_Redmine_on_CentOS_5.
Redmine is based on the Ruby on Rails framework. I've requested help on
that site but haven't been able to get any help. I feel like a baby,
but please please please help.


I went with:

ruby-1.8.7.p358.tar.gz (per the article)
rubygems-1.4.2.tgz (per the article)
redmine-2.0.3.tar.gz (instead of redmine-1.3.2.tar.gz as done with the
tutorial)

Then when I got to the bundle install part...

[root@vps redmine]# bundle install
You cannot specify the same gem twice with different version
requirements. You specified: i18n (~> 0.6.0) and i18n (= 0.4.2)


So I comment out gem "i18n", "0.4.2" in /home/site1/redmine/Gemfile

[root@vps redmine]# bundle install
You cannot specify the same gem twice with different version
requirements. You specified: coderay (~> 1.0.6) and coderay (~> 0.9.7)

So I comment out gem "coderay", "~>0.9.7" in /home/site1/redmine/Gemfile

[root@vps redmine]# bundle install
Fetching gem metadata from http://rubygems.org/.......
Fetching gem metadata from http://rubygems.org/.......
Bundler could not find compatible versions for gem "rack":
In Gemfile:
rails (= 3.2.6) ruby depends on
rack (~> 1.4.0) ruby

rack (1.1.0)

Could anyone help? Please please please again (dang, I am a baby). Thank
you

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

hi all,


I am doing some unit tests on my own ror environment(Ubuntu 11.10, ruby 1.9.3, rails 3.2.4), but I found that the fixture data did not insert into the database.

test 'some test' do
  pp articles # I have an Article model 
end #test

Then I type the command rake db:test:prepare and rake test:units, the articles variable was en empty array and no exceptions raised.

Could you kindly tell me how can I fix this problem?

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

Folks,

Unless I'm being dumb I cannot find anything on Google search or in the Rails books on how to create a one-to-one polymorphic association
(as apposed to a one-to-many polymorphic association).  New to Rails so please forgive my ignorance. The situation is simple: I have the
following models/tables

- Person
generic concept (name, age, nationality, etc) which I want to attach polymorphically to concrete models suchs

- Staff
- Mother
- Farther
- Child
- etc

concrete class contain additional type specific information which I do not want nullable hence STI is not desirable
and would result in a sparse table.

If it matters this is for a charity.

Regards, Neil

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/FT6d45W1HIgJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

In the Rails documentation, it shows Association::AssociationProxy,
and I know that in ruby :: operator is a reference to a constant, and
a constant can either be a module or a class. So I ask because I'm
just curious how the two behave together. Thanks for response.

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

I'm saying that active_record called on AssociationReflection seems to
just return the class object itself. For example:

Account.reflect_on_association(:users).active_record # => Account

What's the point of that? Can't you just do Account.class?

On Jul 31, 5:42 am, Frederick Cheung <frederick.che...@gmail.com>
wrote:
> On Tuesday, July 31, 2012 2:09:41 AM UTC+1, John Merlino wrote:
>
> > Account.reflect_on_association(:users).active_record
> >  => Account(id: integer, name: string, created_at: datetime,
> > updated_at: datetime, ancestry: string, street_address: string, city:
> > string, postal_code: string, state: string, country: string,
> > street_address2: string, account_type_id: integer, client_logo:
> > string, subdomain: string, email: string, phone: string)
>
> > What it returns is not the Account object.
>
> > According to documentation, it "Returns the value of attribute
> > active_record".
>
> >http://rubydoc.info/docs/rails/3.0.0/ActiveRecord/Reflection/MacroRef...
>
> > Well, that's not too informative...
>
> > What's your question (and what the relationship with  your subject line?) ?
>
> Fred

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

> > How to learn basics of Ruby and make learning interesting? How you all
> > started with Ruby? Whether Ruby first or Rails first?
> >
> I personally started with Ruby first. I like the books from The
> Pragmatic Bookshelf. (pragprog.com)

Ruby first. Rails is a great tool for quickly generating crud web interfaces and dealing with databases (and so much more). But, what it outputs is Ruby code, and if you understand ruby, you will understand much of the magic that is Rails.

Better yet, you'll be in a position to modify and extend the code that Rails generates to better suit the task at hand and gain a better understanding of things like 'method_missing' which is responsible for much of the magic behind the Rails curtain.

Feel free to check out http://RubyTalkTips.com. It's an open source website for Ruby showing what I have considered to be some of the best ruby language tips over the past few years from the Ruby Talk mailing list.

-- Steve Downie
________________________________________________
aka Capt. Downer
Sea of Anarchy Yacht Club
http://rubytalktips.com
email: captdowner@gmail.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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

Hello Salvatore,

I think using things like spork or the like is just a band-aid and
they are not a solution to the real problem which is the design and
mixing things all together in rails provided and known things,
specially controllers and models. If we have good design with Single
Responsibility Principle and Separation of Concerns we can have
incredibly fast tests with focused pieces in our design. And we only
need rake or those stuff for running our rails-specific tests (like
controller tests, model tests, etc.) and those tests wont need to be
run as frequently as domain-logic tests. domain-logic tests should be
run so frequently during the red-green-refactor cycle all the time
and we should benefit from the quick feedback and other things which
are provided by having fast tests.

I recommend you to watch this interesting talk by Corey Haines ->
http://arrrrcamp.be/videos/2011/corey-haines---fast-rails-tests/ it'll
be great explanation of the things I've just mentioned with perfect
details and examples.

Hope that helps.
Best Regards

--
Sam Serpoosh
Software Developer: http://masihjesus.wordpress.com
Twitter @masihjesus

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

Hi!


When I'm creating an application for a project of my own I usually use Active Admin or something for my admin area and code everything else myself. The backend interface is not always perfect but it's OK because only I will use it. The few quirks and weird stuff is OK because I know how everything works. The non-intuitive gets intuitive to me because I'm the developer :)

When creating something for a client it may be more important with a good and intuitive interface, easy content management etc. In the PHP world i guess most people use something like Joomla!, Drupal or Wordpress for these kind of projects. They are easy to use, have the WYSIWYG editors etc. that the client can use to create and manage the content.


- What do you use when developing in RoR for a client? Is it only 100% custom applications (with the use of some gems of course, like maybe devise etc.)?
Is anyone using any CMS in the RoR world? I have seen a few, like LocomotiveCMS, RadiantCMS etc, but I have never used one in a project.

What are your experiences here?

Cheers!

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/u9u3X-kSS5MJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

Sounds like you want to look at collection_name  on your class. 


More here...




On Tue, Jul 31, 2012 at 4:47 PM, Tom Allison <tom@tacocat.net> wrote:

Ran into a great problem.  REST, as it's implimented via Rails, identifies the URL as a plural in every case.  So you would retrieve a single issue through /issues/<insert key here>.  This seems to be technically incorrect.

I find other (non-Rails) documentation talking about this being singular for getting a single issue and plural for a list.

And this is also how the site I'm trying to access is configured.  Which means that every time I try to GET a single issue the ActiveResource is calling for /issues/<insert key here> instead of the correct /issue/<insert key here>.

Does anyone know of a way to workaround this problem using ActiveResource?


Maybe I should ask if anyone else agrees that this is a problem in the implementation of the REST api in ActiveResource?

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

Ran into a great problem.  REST, as it's implimented via Rails, identifies the URL as a plural in every case.  So you would retrieve a single issue through /issues/<insert key here>.  This seems to be technically incorrect.

I find other (non-Rails) documentation talking about this being singular for getting a single issue and plural for a list.

And this is also how the site I'm trying to access is configured.  Which means that every time I try to GET a single issue the ActiveResource is calling for /issues/<insert key here> instead of the correct /issue/<insert key here>.

Does anyone know of a way to workaround this problem using ActiveResource?


Maybe I should ask if anyone else agrees that this is a problem in the implementation of the REST api in ActiveResource?

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

I personally started with Ruby first. I like the books from The
Pragmatic Bookshelf. (pragprog.com)

Douglas Lovell
www.wbreeze.com

On 07/31/2012 01:40 PM, Rubyist Rohit wrote:
> I want to build a small GUI application that makes sense and not just a
> Hello World application. I tried wxRuby, FxRuby and other libraries but
> all seem to complicate things.
>
> How to learn basics of Ruby and make learning interesting? How you all
> started with Ruby? Whether Ruby first or Rails first?
>

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

Hi.

Ruby, first so you can get along with Rails more easily, because in the first place, Rails is built using Ruby language. ;)

Try Ruby @ tryruby.org  that's where I learned the basics of Ruby. ^_^ After that, head on to CodeSchool and try RailsForZombie course, which is FREE. :)


On Wednesday, August 1, 2012 1:40:49 AM UTC+8, Ruby-Forum.com User wrote:
I want to build a small GUI application that makes sense and not just a
Hello World application. I tried wxRuby, FxRuby and other libraries but
all seem to complicate things.

How to learn basics of Ruby and make learning interesting? How you all
started with Ruby? Whether Ruby first or Rails first?

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Gwaqqu8NwaEJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

Hi,

I'm working on rails project, on version 3.2.6, so I have problems with
assets in production mode. On localhost everything works fine because
assets are in folder app/assets, but on production server assets are
precompiled
and set in public folder.

Now in images folder in assets I created new folder pdfimages, so path
is
assets/images/pdfimages. I have action in controller which enables file
to upload. File should be uploaded to pdfimages folder. So how can I do
this on production. Is the correct path

'assets/pdfimages/image.jpg' because it doesnt work for me?

Also, what is correct path to json file stored in assets/javascripts
when defining it from jquery on production server?

Is it assets/example.json

Thanks in advance

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

Vincent Lin wrote in post #1070656:
> git://github.com/vincentopensourcetaiwan/vocabulary.git
> This is my source codes.
>
> I got two models, Book and Word.
>
> class Book < ActiveRecord::Base
> has_and_belongs_to_many :words
> end
>
> class Word < ActiveRecord::Base
> has_and_belongs_to_many :books
> end
>
> I got a Join Tables for has_and_belongs_to_many Associations
>
> class CreateBooksWords < ActiveRecord::Migration
> def self.up
> create_table :books_words, :id => false do |t|
> t.integer :book_id
> t.integer :word_id
>
> t.timestamps
> end
> end
>
> def self.down
> drop_table :books_words
> end
> end
>
> Now I want to create a form, and user can insert words into a book.
> How do I do that?

There are some conceptual issues here.
If this is in fact a many-to-many relationship between books and words
so that, a book can have many words, and a word can be in many books,
then:

Don't think of "i want to add words to a book", but think of "I have a
word, and i have a book, and i want to build a relationship between the
two."
So the form you're talking about is not a form on words and books, but a
form about a single model: book_word_relationship (name it whatever you
like). You will have a relationship_controller which will handle #create
and #destroy actions. At this point the form should be trivial. The
#create action will take as parameters the book_id and word_id. Or more
appropriately @book.book_word_relationships.build(params[:word).

This means you will need a proper model and controller to handle these
relationships. Which also means that a HABTM relationship is not
appropriate and you should use has_many :through=>'relationship'.

This railscast has some good advice about the front-end of a many-many
relationship:
http://railscasts.com/episodes/163-self-referential-association
don't worry about the self-referential part.

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

I suggest opening your console - type Person - the console should return to_s of the class - if not, the person model isn't in your path

better yet, take this opportunity to write some tests - start with the Person model

On 2012-07-31, at 2:38 PM, masta Blasta wrote:

> deal bitte wrote in post #1070764:
>>
>> Project.rb
>> ------------------
>> class Project < ActiveRecord::Base
>> has_and_belongs_to_many :people
>> has_many :documents, :conditions => ["project_id =?", self.id ]
>> ..
>> ..
>> end
>>
>> application_helper.rb
>> --------------------------
>>
>> def find_projects
>> user = Person.find(session[:userid])
>> projects = Project.find(:all)
>> ..
>> ..
>> ..
>> end
>>
>> I am getting an error
>> undefined method `id' for #<Class:0x182237ac> (self.id is the problem
>> guess)
>
> Not really answering your question here, but i would restructure some of
> this code as follows, to better go with rails 3
>
> class Project < ActiveRecord::Base
> has_many :people, :through => 'people_project_join_table'
> has_many :documents #:foreign_key => 'project_id' is default for this
> relationship. Don't need.
> ..
> ..
>
>
> def find_projects
> user = Person.find(session[:userid])
> projects = Project.all
> ..
> ..
> ..
> end
> --
>
> Beyond that, whenever you get an error like 'undefined method for
> class', first make sure you're in fact working with the class you think
> you're working with by doing myobj.class
>
> a common slip-up for me is trying to use object methods on an array of
> said objects. Most scopes and associations will return arrays.
>
> --
> 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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

deal bitte wrote in post #1070764:
>
> Project.rb
> ------------------
> class Project < ActiveRecord::Base
> has_and_belongs_to_many :people
> has_many :documents, :conditions => ["project_id =?", self.id ]
> ..
> ..
> end
>
> application_helper.rb
> --------------------------
>
> def find_projects
> user = Person.find(session[:userid])
> projects = Project.find(:all)
> ..
> ..
> ..
> end
>
> I am getting an error
> undefined method `id' for #<Class:0x182237ac> (self.id is the problem
> guess)

Not really answering your question here, but i would restructure some of
this code as follows, to better go with rails 3

class Project < ActiveRecord::Base
has_many :people, :through => 'people_project_join_table'
has_many :documents #:foreign_key => 'project_id' is default for this
relationship. Don't need.
..
..


def find_projects
user = Person.find(session[:userid])
projects = Project.all
..
..
..
end
--

Beyond that, whenever you get an error like 'undefined method for
class', first make sure you're in fact working with the class you think
you're working with by doing myobj.class

a common slip-up for me is trying to use object methods on an array of
said objects. Most scopes and associations will return arrays.

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

Use either spark or parallel_tests


Dheeraj Kumar

On Tuesday 31 July 2012 at 11:11 PM, Salvatore Pelligra wrote:

Testing with rake is REALLY time consuming! Every time I have to run a
test, it eat up something like 4 to 6 seconds, only for start up O_O

There's nothing we can do to speed up? Perhaps something like spork?

--

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

tl;dr: nested attributes isn't setting the belongs_to association

I have these two models right now:

class Organization < ActiveRecord::Base
  has_many :groups
  belongs_to :main_group, :class_name => Group.name, :foreign_key => :main_group_id, :autosave => true

  validates_presence_of :main_group

  accepts_nested_attributes_for :main_group, :allow_destroy => true
end

class Group < ActiveRecord::Base
  belongs_to :organization, :autosave => true

  validates_presence_of :organization
end

I want to create a nested form that will create a new User along with the Organization along with a new Group. My form code is the following:
<%= form_for(@user) do |f| %>
      <%= f.label :email, "Email Address" %>

      <%= fields_for :organization, @organization do |org_f| %>
        <%= org_f.label :name, "Organization Name" %>
        <%= org_f.text_field :name %>
        <% if org_f.object.new_record? %>
          <%= org_f.fields_for :main_group do |main_f| %>
            <%= main_f.label :name, "Your Org's Main Group" %>
            <%= main_f.text_field :name %>
          <% end %>
        <% end %>
      <% end %>
<% end %>

Here's my Controller's action code that's giving me errors:
  def create
    @user = User.new(params[:user])
    if !params[:secret].to_s.empty?
      @user.accept_invitation(params[:organization][:id], params[:secret])
      @organization = @user.organizations.first || Organization.new
    else
      @organization = @user.organizations.build(params[:organization].slice!(:id))
      @organization.main_group.organization = @organization
    end

  def create
    if !params[:secret].to_s.empty?
      @user.accept_invitation(params[:organization][:id], params[:secret])
      @organization = @user.organizations.first || Organization.new
    else
      @organization = @user.organizations.build(params[:organization].slice!(:id))
      # If I comment out the following line, it'll break
      #  @organization.main_group.organization = @organization
    end
  end

My question is: is there a more elegant way to set the #main_group's association to the organization than the commented line above?

Thanks everyone.

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/onfiauXvQ7YJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

Testing with rake is REALLY time consuming! Every time I have to run a
test, it eat up something like 4 to 6 seconds, only for start up O_O

There's nothing we can do to speed up? Perhaps something like spork?

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

I want to build a small GUI application that makes sense and not just a
Hello World application. I tried wxRuby, FxRuby and other libraries but
all seem to complicate things.

How to learn basics of Ruby and make learning interesting? How you all
started with Ruby? Whether Ruby first or Rails first?

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

I used to rescue an Exception like this:


  unless Rails.application.config.consider_all_requests_local
    rescue_from Exception, :with => :render_error
  end

But this is hard to test.

So I removed the condition in the controller and added it in the render_error method itself: raise e if request.local?

And in my test I overwrite ActionDispatch::Request

class ::ActionDispatch::Request
  def local? ; false end
end

What do you think?

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/R5vuMlwn86AJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

how to get the image and save from this googleChart api URL. I am trying to do this for 3 days with open-uri, but i couldn't proceed that?


Thanks
vishnu

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/eo4YTVdVthsJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails



Also note that before_save (and pretty much all the callbacks) take :if and :unless parameters, like so

before_save do_something, :if => Proc.new {|model| model.some_boolean_attr_or_method }



On Jul 31, 2012, at 9:11 AM, jsnark wrote:



On Monday, July 30, 2012 6:40:51 PM UTC-4, pavling wrote:
On 30 July 2012 22:39, jsnark wrote:
> I understand the problem now, but I do not see the solution.  The model has
> a before_save filter that is causing the password to be reset.  How do I
> stop this on an update?

The same way I said before - only run it if the password has been populated:

   def encrypt_password
     self.encrypted_password = encrypt(self.password) unless
self.password.blank?
   end

But you will probably need to add same validation to ensure there is
an encrypted_password - otherwise it would be possible to create
accounts with blank passwords...

Thank you.

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/RIfvsT32vIsJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

Issue resolved:
http://stackoverflow.com/questions/11713427/form-for-with-module-and-namespace

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

Hi Rubyists!

Have you ever considered working in London, the Ruby-on-Rails capital of
Europe? If you've ever looked for a job in England before you may have
heard of me I'm the #1 RoR recruiter in the UK.

Salaries are going through the roof!
Senior/Lead Ruby-on-Rails Developer: up-to-£70k

Mid Level Ruby-on-Rails Developer: up-to-£55k

Junior Ruby-on-Rails Developer: up-to-£30k

Before you go any further
- add me to skype: LouisGB1
- add me to Linkedin: http://uk.linkedin.com/in/louisbeardsley (send a
request to louisror@gmail.com)

There is a huge variety of teams working on some very exciting web
applications in a whole host of industries.

I have the connections and the marketing knowledge to help you...

- Rewrite your CV to present your skills and experience in the best
possible way.
- Schedule you multiple interviews so you only have to come over to the
UK on one trip rather then multiple trips.
- Fully prepare you for interviews.

Get in contact and we can discuss what you are looking for ASAP!
SKYPE ME TODAY! - LOUISGB1


[Louis Goff-Beardsley]
> Ultra-Specialized Independent Ruby-on-Rails Recruitment.
> Software Sales, Business Development & AC Acquisition for the RoR
community.
> Skype: LouisGB1
> Email: LouisRoR@gmail.com
> Land Line: (+44) 0 1183 276 608
> Mobile: (+44) 0 7825 338 966
> Twitter: @LouisRoR
> LinkedIn: http://www.linkedin.com/in/louisbeardsley
__________ __ __ __________
\______ \_____ |__| | ______ \______ \ ____ ____
| _/\__ \ | | | / ___/ | _// __ \_/ ___\
| | \ / __ \| | |__\___ \ | | \ ___/\ \___
|____|_ /(____ /__|____/____ > |____|_ /\___ >\___ >
\/ \/ \/ \/ \/ \/

IRC: LouisGB - irc.freenode.org #LRUG, #NWRUG, #ruby, #rubyonrails

"Louis found my dream job for me. He took a lot of time to get to know
me and what I was looking for. He's obviously got a lot of connections
and was able to offer me a variety of roles. Louis actually knows what
he's talking about when it comes to Ruby-on-Rails, which is pretty much
unique for a recruiter. He gave me advice on what course of action is
best for me, helped me rewrite my CV as I was underselling myself and
prepared me for my interviews. Highly recommended!" Michal K - May 9,
2012

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails



On Monday, July 30, 2012 6:40:51 PM UTC-4, pavling wrote:

On 30 July 2012 22:39, jsnark wrote:
> I understand the problem now, but I do not see the solution.  The model has
> a before_save filter that is causing the password to be reset.  How do I
> stop this on an update?

The same way I said before - only run it if the password has been populated:

   def encrypt_password
     self.encrypted_password = encrypt(self.password) unless
self.password.blank?
   end

But you will probably need to add same validation to ensure there is
an encrypted_password - otherwise it would be possible to create
accounts with blank passwords...

Thank you.

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/RIfvsT32vIsJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails



On Monday, 30 July 2012 23:25:45 UTC-4, Me wrote:

Is there something I need to do to the data_type to make it recognize it as a method?
wrong number of arguments (3 for 0)
<div class="control-group">  48:             <%= f.label question.name.to_sym, :class => 'control-label' %>  49:             <div class="controls">  50:               <%= question.data_type "person[person_question_ids][]", question.id, nil %> - <%= ' allergic to shellfish?' %>  51:             </div>  52:           </div>



Wait, what? You posted the correct code in your original post, but this isn't that code. Line 50 here is saying, "call the data_type method on the question object with these three parameters". The generated accessor doesn't understand the parameters, and you get the error.

If you want to call a method whose name is selected at runtime, you *need* to use send.

--Matt Jones

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/HtXEgsuq8MEJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

I have installed the latest version of rails and jruby. I have copied
all my files from rails 2.3.5 version and am trying to bring all to work
in this version

Project.rb
------------------
class Project < ActiveRecord::Base
has_and_belongs_to_many :people
has_many :documents, :conditions => ["project_id =?", self.id ]
..
..
end

application_helper.rb
--------------------------

def find_projects
user = Person.find(session[:userid])
projects = Project.find(:all)
..
..
..
end

I am getting an error
undefined method `id' for #<Class:0x182237ac> (self.id is the problem
guess)

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

yes this will send one mail with attachment of image.png. But when i open or download that image, that is empty.?



imageurl = https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=5&choe=UTF-8
require 'open-uri'
class UserMailer < ActionMailer::Base
  default :from => "mail@example.com"
  
  def welcome_email(imageurl,mailid)

    attachments['QR.png'] = {:mime_type => 'image/png',
                                     :content => open(URI.parse(imageURL))}
    mail(:to => mailid,
    :subject => "Code",
    :body => "Code")
  end
end

Thanks 
vishnu

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/bPjFh56Cq5EJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails


On Tuesday, July 31, 2012 2:09:41 AM UTC+1, John Merlino wrote:


Account.reflect_on_association(:users).active_record
 => Account(id: integer, name: string, created_at: datetime,
updated_at: datetime, ancestry: string, street_address: string, city:
string, postal_code: string, state: string, country: string,
street_address2: string, account_type_id: integer, client_logo:
string, subdomain: string, email: string, phone: string)

What it returns is not the Account object.

According to documentation, it "Returns the value of attribute
active_record".


http://rubydoc.info/docs/rails/3.0.0/ActiveRecord/Reflection/MacroReflection#active_record-instance_method


Well, that's not too informative...


What's your question (and what the relationship with  your subject line?) ?

Fred

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/R9_hujNydvsJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

On 31 July 2012 06:00, thil <thil.1212@gmail.com> wrote:
>
> Hi All,
>
> I have one question below:
>
> How can I create app by specifying the rails version.
>
> for example I have local rails gem versions (2.3.5, and 2.3.10) how I can
> create rails app => 2.3.10 but default rails gem point to 2.3.5.
>
> I have google I found that by specifying `rails _2.3.10_ new demo` will
> help but is not working instead it creating new app in the name "_2.3.10_"

I don't remember how to do it on rails 2 (the method you have tried is
for rails 3), but I think if you type
rails -h
it will show you all the switches, one of which should be for
specifying the version.

Ideally you should not be using rails 2 for new applications however.

Colin

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

On 31 July 2012 08:13, saritha chakilala <lists@ruby-forum.com> wrote:
> Can any one help how to integrate barcode reader into my Application.
>
> What I want actually is that,
> By Capturing the value of barcode(registrtion_id) all other fields of
> that particular record need to autofill.
>
> ***I Am Looking For Your Valuable Reply **8
>
> Thanks in Advance.

Most barcode scanners are just another type of input device (like a
keyboard or mouse). When they scan, they send the series of digits
that the barcode represents to the computer as keyboard input - just
as if the user had typed them.

All you need to do is set up a form with a "barcode number" input
field, which is observed for any changes. That value can be posted to
your app and you can return whatever response you want.

If you want to get funky, depending on the features of your scanner,
you can set the scanner up to send a special character code before it
sends the rest of the characters, and you could use javascript to
watch out for the special character, and capture everything that comes
after...

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails

Can any one help how to integrate barcode reader into my Application.

What I want actually is that,
By Capturing the value of barcode(registrtion_id) all other fields of
that particular record need to autofill.

***I Am Looking For Your Valuable Reply **8

Thanks in Advance.

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruby on Rails Monday, July 30, 2012

try referring to the attribute like this instance[:message] where instance it the name of the instance of course, e.g outgoing_message_recipient[:message]

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

You can access the object by using

f.object

then you can do 

f.object.send

here 'f.object' return an instance of Question, but i think that whatever you are trying to do you are doing it wrong, can you elaborate in what you are trying to do?


--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails


 I have google I found that by specifying `rails _2.3.10_  new demo`  will help but is not working instead it creating \


the 'new' command did not exists in rails before rails 3, back then there was a different script for  generators

script/generate controller

is now 

rails g controller


so back then the 'rails' script was only for making apps, now it accepts commands like generate, destroy and more. If you want to see who to use it in rails 3 check out this link
 

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails


Hi All,

I have one question below:

How can I create app by specifying the rails version.

for example I have local rails gem versions (2.3.5, and 2.3.10) how I can create rails app => 2.3.10 but default rails gem point to 2.3.5.

 I have google I found that by specifying `rails _2.3.10_  new demo`  will help but is not working instead it creating new app in the name   "_2.3.10_"


Can any help on the same.

Thanks,
Senthil Srinivasan

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/A5iPlNN8nl0J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ruby on Rails

Is there something I need to do to the data_type to make it recognize it as a method?
wrong number of arguments (3 for 0)
    <div class="control-group">  48:             <%= f.label question.name.to_sym, :class => 'control-label' %>  49:             <div class="controls">  50:               <%= question.data_type "person[person_question_ids][]", question.id, nil %> - <%= ' allergic to shellfish?' %>  51:             </div>  52:           </div>

On Mon, Jul 30, 2012 at 9:17 PM, Dheeraj Kumar <a.dheeraj.kumar@gmail.com> wrote:
Of course! Are you encountering any problems with that?


Dheeraj Kumar

On Tuesday 31 July 2012 at 3:31 AM, Me wrote:

Can you do f.send in a form?  I have questions and the data type stored in a db.

<% Question.all.each do |question| %>
          <div class="control-group">
            <%= f.send(:label, question.name), :class => 'control-label' %>
            <div class="controls">
              <%= f.send(question.data_type.to_sym, :question, :name) %> - <%= ' allergic to shellfish?' %>
            </div>
          </div>
        
        <% end %>

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/6K79gq2KHPYJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
"In matters of style, swim with the current; in matters of principle, stand like a rock." 
Thomas Jefferson

--
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 unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.