simple-form

How to put two divs on the same line with CSS in simple_form in rails?

百般思念 提交于 2019-12-12 08:39:53
问题 Putting two divs on the same line is an old question. But I can't find a solution when working with simple_form in rails. What I want to do is to display content and its label on the same line. The width of the label is 125px ( .left ) and the content is on the right ( .right ). The text in the label is aligned to the right and the text in content is aligned to the left. Here is the HTML: <form id="new_production" class="simple_form new_production" novalidate="novalidate" method="post" action

Rails Carrierwave and Simple Form

梦想与她 提交于 2019-12-12 06:19:51
问题 I have a rails 4 app that I use with simple form and carrierwave. In my profile view, I have a form that includes a request for users to nominate their university, as follows: <%= f.collection_select :university, University.all, :id, :name %> In my university model, I create universities and add their associated logos: { :class => 'question-project' }, placeholder: 'Your uni name', :input_html => {:style=> 'width: 650px', class: 'response-project'} %> <%= f.label :'Your university logo',

Nested simple_form with polymorphic association. Unpermited parameter

自作多情 提交于 2019-12-12 06:01:57
问题 It's a lot of question about it all around, but I can't find the answer. I've: group.rb class Group < ActiveRecord::Base has_many :descriptions, :as => :describable accepts_nested_attributes_for :descriptions end description.rb class Description < ActiveRecord::Base belongs_to :describable, :polymorphic => true end groups_controller.rb def update @group = Group.find(params[:id]) if @group.update_attributes(group_params) flash[:success] = "yes" redirect_to groups_path else render 'edit' end

How to add html link for a simple_form field in rails 3.2?

北战南征 提交于 2019-12-12 03:43:00
问题 Here is the quote_task field in simple form. <%= f.input :quote_task, :label => t('Quote Task'), :input_html => {:value => @quote_task.id}, :readonly => true %> Now we want to add an embeded html link for the @quote_task.id to show the content of the quote_task. When a user click the id, he will be directed to the content of the quote task. Something like: <%= f.input :quote_task, :label => t('Quote Task'), :input_html => {:value => (link_to @quote_task.id.to_s, quote_task_path(@quote_task.id

How to submit my remote update form via AJAX?

纵然是瞬间 提交于 2019-12-12 03:42:16
问题 I have a form that will edit the record, I want it to use ajax though when submitting, = simple_form_for(@lesson, :html => {"data-type" => :html, :id=>'lesson_form'}, :remote=>true) do |lesson_form| = lesson_form.button :submit, 'Update' but, in the lessons controller at update action, the request.xhr? evaluates 0, although I am setting remote to true at the form options above; request.xhr? does not evaluate to true. So, what am I missing here ? How to use ajax when update my record ? Isn't

Rails 4 - Associations - adding team mates to teams

假如想象 提交于 2019-12-12 03:28:26
问题 I'm having trouble with my Rails 4 app. I'm trying to follow this tutorial https://coderwall.com/p/rqjjca/creating-a-scoped-invitation-system-for-rails with some modifications. The tutorial skips over a few steps that are considered by the writer to be too easy to bother with - I think that's where I'm getting stuck. I have models for profile, project, team and user. The associations are: Profile.rb has_many :teams, foreign_key: "team_mate_id" has_many :team_projects, through: :teams, source:

Adding a css class to select in Rails

人走茶凉 提交于 2019-12-12 02:18:26
问题 I've been trying to make the following class applies on the select/dropdown, but I couldn't! = f.select attr, [1,2,3], class: 'form-control', include_blank: true I tried to read the rails code, here and here. it's like it is not implemented ? but it works for text fields: = f.search_field attr, options.merge(class: 'form-control') I'm using slim and simple_form 回答1: select takes 2 hash options, first for 'select options' and another for 'html'. Try following: = f.select(attr, [1,2,3], {

Sign Up Form Error: undefined method `model_name' for NilClass:Class

大憨熊 提交于 2019-12-12 02:04:13
问题 So this is my first attempt kind of just going without tutorial direction on building a site on RoR. Running into some trouble setting up my email signup form. I think there is an issue with how my model is setup or connected but not too sure. Getting "undefined method `model_name' for NilClass:Class" as the error". signup.rb class Signup < ActiveRecord::Base validates_presence_of :email def change create_tabe :quotes do |t| t.string :email end end end signups_controller.rb class

Rails, Simple Form, and Client Side Validations aren't working

眉间皱痕 提交于 2019-12-12 00:25:46
问题 My model: class Hotel < ActiveRecord::Base attr_accessible :name belongs_to :user has_many :room_types validates :user_id, presence: true validates :name, presence: true, length: { in: 2..15 } end The form code: <%= simple_form_for @hotel, :validate => true do |f| %> <%= f.input :name %> <%= f.submit 'Create Hotel' , :class => 'btn btn-primary', :type => 'submit' %> <% end %> There doesn't seem to be any client side validation being performed. I can submit the form without filling in any

How to use a form to connect has_one through relationship with condition

狂风中的少年 提交于 2019-12-11 23:33:08
问题 I have a has_one through relationship with a condition that connects trips and addresses in my app. Each trip has two addresses: the origin, and the destination. Addresses can be used in many different trips, and can be either origins or destinations. In the app, trips and addresses are connected by a model called TripLocation, which as a Boolean column "destination" which sets whether the address is functioning as a destination for the trip or not. To see more about that relationship, see