Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8478385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:43:52+00:00 2026-06-10T18:43:52+00:00

I have a formtastic form to gather parameters for report generation. I know formtastic

  • 0

I have a formtastic form to gather parameters for report generation. I know formtastic is designed to be used with models but I need to use it here as the form is in an activeadmin page.

It’s all working well but I can’t set a default value for the selects. I’m willing to implement a “despicable hack” to get this working. I’d prefer not to implement a fake model
just to set default values on a form.

The form code looks like this

<%= semantic_form_for "report", :url => report_admin_payments_path do |f| %>
  <%= f.inputs do %>
    <%= f.input :report_type, :as => :select, :collection => report_types, :input_html => {:style => "width:180px"}  %>    
    <%= f.input :start_date, :as => :string, :input_html => {:class => 'datepicker', :style => "width:60px", :value => 1.month.ago.strftime("%Y-%m-%d")} %>
    <%= f.input :end_date, :as => :string, :input_html => {:class => 'datepicker', :style => "width:60px", :value => Time.zone.now.strftime("%Y-%m-%d")} %>
    <%= f.input :country, :as => :select, :collection => locales, :input_html => {:style => "width:180px"}%>
  <% end %>
  <%= f.actions :submit %>
<% end %>

Thanks in advance,

Matt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:43:53+00:00Added an answer on June 10, 2026 at 6:43 pm

    This or something similar should meet your needs.

    class LightModel
    
      # Subclass this for a model that looks like an ar model but has no persistence
      # good for formtastic forms
    
      include ActiveModel::Naming
      include ActiveModel::Validations
    
      def initialize(attributes = {})
        @attributes = attributes
      end  
    
      # read only atm
      def method_missing(m, *args, &block)
        @attributes[m]
      end  
    
    end
    

    Thanks,

    Matt

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use formtastic to create form but I don't have a
I have rails 3.1.3 and formtastic 2.0.2. I'm using the most basic form you
I have: form.input :duration, as: select, collection: {} I need: <option value= data-price=XXX></option> Rails
I have a bootstrap formtastic form which was passing all of my rspec tests.
I'm building a form in Rails3 and Formtastic. I have the following field: <%=
I am setting up a formtastic form where a number of fields need to
I have a list of vendors. I need to put them in a formtastic
I have a formtastic form like the following: = semantic_form_for @record, :remote => true,
I have the following form with Formtastic: = semantic_form_for @user, :url=> url_for(register_path), :html =>
I have this formtastic field in a form where an user input his credit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.