Fetching checkbox name from database


#1

Hi all, I am new to this place and ruby on rails as well.

I am developing a web application where I have to create a form which
displays the checkboxes. The names of these checkboxes have to be
fetched from a database. Can some one help me out of this ?


#2

<%= check_box :modelname, :attribute, options, on_value, off_value %>

Example:

check_box “post”, “validated” # post.validated? returns 1 or 0

check_box “puppy”, “gooddog”, {}, “yes”, “no”

Just use it…
If you can’t understand, get back again


#3

some one please help me out. :frowning:


#4

Anyone out there? please have a look at my query also. :frowning:


#5

currently i am using this in my view, which makes it pretty hard
coded…can u suggest something else in place of it(which dynamically
fetches the checkbox names from a database)

Also, I want to use two databases(one for fetching the checkbox names,
and the other is for my application). Do I need to include some extra
code for it?

Subscribe

Subscribe

<% form_for :user do |form| %>

Enter Your Details

Parameter1:
<%= form.check_box :parameter1 %>

Parameter2:
<%= form.check_box :parameter2 %>

Parameter3:
<%= form.check_box :parameter3 %>

<%= submit_tag “Subscribe!”, :class => “submit” %>

<% end %>

On Dec 10, 6:13 pm, Priya B. removed_email_address@domain.invalid


#6

On Wed, Dec 10, 2008 at 7:49 PM, Navi023 removed_email_address@domain.invalid
wrote:

currently i am using this in my view, which makes it pretty hard
coded…can u suggest something else in place of it(which dynamically
fetches the checkbox names from a database)

Also, I want to use two databases(one for fetching the checkbox names,
and the other is for my application). Do I need to include some extra
code for it?

The doc for ActiveRecord::Base has a section titled
“Connection to multiple databases in different models”

Perhaps that would be a good place to start :slight_smile:


Hassan S. ------------------------ removed_email_address@domain.invalid