Forum: Ruby on Rails Select updates database?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
101407ef5f93947dd51b6d2e8f0a6cc9?d=identicon&s=25 Amitabh A (Guest)
on 2009-03-23 19:48
(Received via mailing list)
I am running on Rails 2.2.2 on Solaris (and also on my mac) against
mysql. For some reason, when I use a select in the partial, the
database does not get updated with the changed value. I am using
checkbox for other fields which works perfectly.
I can provide more information if needed, but I would like the field
to work as a dropdown instead of a text field.

My Model:
      has_and_belongs_to_many :industries, :join_table =>
"grant_loans_industry", :foreign_key =>
"grant_loans_id", :association_foreign_key => "industry_id"
      belongs_to :state

My Controller:
  before_filter :login_required

  layout "admin"
  active_scaffold :grant_loan do |config|
    config.list.columns = [:agency, :gov_type, :title, :url]
    config.columns.exclude  :state_name
    config.label = 'Grants and Loans'
    columns[:state].form_ui = :select
    columns[:industries].form_ui = :select
  end


Partial:
  <%=  select :grant_loan, :business_type, ['for_profit','non_profit'],
{:selected => @record.business_type, :prompt => "Select The Business
Type"}, {} %>
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-03-23 19:52
(Received via mailing list)
On Mar 23, 6:14 pm, Amitabh A <chanak...@gmail.com> wrote:
> I am running on Rails 2.2.2 on Solaris (and also on my mac) against
> mysql. For some reason, when I use a select in the partial, the
> database does not get updated with the changed value. I am using
> checkbox for other fields which works perfectly.
> I can provide more information if needed, but I would like the field
> to work as a dropdown instead of a text field.
>

ActiveScaffold expects things to be named in particular ways, I expect
the select box you've generated isn't created parameters named the way
it wants. You might be able to work out what the parameters should
look like by letting activescaffold generate what it wants (ie don't
use your partial) and seeing where the differences are. There's also
an activescaffold google group out there.

Fred
101407ef5f93947dd51b6d2e8f0a6cc9?d=identicon&s=25 Amitabh A (Guest)
on 2009-03-24 15:06
(Received via mailing list)
Thanks, I will look at the active_scaffold group as well.
If I don't find the answer, I will post there.

On Mar 23, 2:51 pm, Frederick Cheung <frederick.che...@gmail.com>
This topic is locked and can not be replied to.