RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: jaykilleen
Site: http://jaykilleen.com
I bootstrap the advanced search form as follows:
index.html.erb <%= search_form_for @search, url: search_customers_path, method: :post, :html => {:class => "form-horizontal"} do |f| %> <%= f.condition_fields do |c| %> <%= render "condition_fields", f: c %> <% end %> <p><%= link_to_add_fields "Add Conditions", f, :condition %></p> <div class="form-group"> <div class="row col-md-4"> Sort: <%= f.sort_fields do |s| %> <%= s.sort_select({}, :class => 'form-control row_spacer') %> <% end %> </div> </div> <div class="row"> <button type="submit" class="btn btn-success">Submit</button> <%= link_to "back", customers_path, class: "btn btn-danger" %> </div> <% end %>
<%= search_form_for @search, url: search_customers_path, method: :post, :html => {:class => "form-horizontal"} do |f| %> <%= f.condition_fields do |c| %> <%= render "condition_fields", f: c %> <% end %> <p><%= link_to_add_fields "Add Conditions", f, :condition %></p> <div class="form-group"> <div class="row col-md-4"> Sort: <%= f.sort_fields do |s| %> <%= s.sort_select({}, :class => 'form-control row_spacer') %> <% end %> </div> </div> <div class="row"> <button type="submit" class="btn btn-success">Submit</button> <%= link_to "back", customers_path, class: "btn btn-danger" %> </div> <% end %>
_conditional_fields.html.erb <div class="form-inline"> <div class="form-group"> <%= f.attribute_fields do |a| %> <%= a.attribute_select({associations: [:category]}, :class => 'form-control') %> <% end %> <%= f.predicate_select({}, :class => 'form-control') %> <%= f.value_fields do |v| %> <%= v.text_field(:value, :class => 'form-control')%> <% end %> <%= link_to "remove", '#', class: "remove_fields btn btn-warning row_spacer" %> </div> <div class="row_spacer"></div> </div>
<div class="form-inline"> <div class="form-group"> <%= f.attribute_fields do |a| %> <%= a.attribute_select({associations: [:category]}, :class => 'form-control') %> <% end %> <%= f.predicate_select({}, :class => 'form-control') %> <%= f.value_fields do |v| %> <%= v.text_field(:value, :class => 'form-control')%> <% end %> <%= link_to "remove", '#', class: "remove_fields btn btn-warning row_spacer" %> </div> <div class="row_spacer"></div> </div>
application_helper.rb def link_to_add_fields(name, f, type) new_object = f.object.send "build_#{type}" id = "new_#{type}" fields = f.send("#{type}_fields", new_object, child_index: id) do |builder| render(type.to_s + "_fields", f: builder) end link_to(name, '#', class: "add_fields btn btn-primary form-group", data: {id: id, fields: fields.gsub("\n", "")}) end
def link_to_add_fields(name, f, type) new_object = f.object.send "build_#{type}" id = "new_#{type}" fields = f.send("#{type}_fields", new_object, child_index: id) do |builder| render(type.to_s + "_fields", f: builder) end link_to(name, '#', class: "add_fields btn btn-primary form-group", data: {id: id, fields: fields.gsub("\n", "")}) end
application.css.scss .row_spacer { margin-top: 5px; }
.row_spacer { margin-top: 5px; }
now it is pretty. Probably won't work for everyone but it sucked trying to figure this out when you are still learning.
So according to comments on this pull request
https://github.com/texticle/texticle/pull/25
Texticle is now called Textacular.
https://github.com/textacular/textacular
Thank you this was very helpful
Thank you!
haha, didn't restart the server
happy! but feeling slightly stupid
Oh man, I got so pumped watching his but can't get it to work. Install the gemfile under development
group :development do gem 'better_errors' gem 'binding_of_caller' end
bundle install bundle update
fire up my app, get to an error, and just the same usual error screen as always.
Running Rails 4 on Ubuntu with Sublime Text 3. Any ideas?
I saw that this is mainly a Mac gemfile but thought that was just for the linking between the error screen and the text editor...
sad.
I bootstrap the advanced search form as follows:
index.html.erb
<%= search_form_for @search, url: search_customers_path, method: :post, :html => {:class => "form-horizontal"} do |f| %>
<%= f.condition_fields do |c| %>
<%= render "condition_fields", f: c %>
<% end %>
<p><%= link_to_add_fields "Add Conditions", f, :condition %></p>
<div class="form-group">
<div class="row col-md-4">
Sort:
<%= f.sort_fields do |s| %>
<%= s.sort_select({}, :class => 'form-control row_spacer') %>
<% end %>
</div>
</div>
<div class="row">
<button type="submit" class="btn btn-success">Submit</button>
<%= link_to "back", customers_path, class: "btn btn-danger" %>
</div>
<% end %>
_conditional_fields.html.erb
<div class="form-inline">
<div class="form-group">
<%= f.attribute_fields do |a| %>
<%= a.attribute_select({associations: [:category]}, :class => 'form-control') %>
<% end %>
<%= f.predicate_select({}, :class => 'form-control') %>
<%= f.value_fields do |v| %>
<%= v.text_field(:value, :class => 'form-control')%>
<% end %>
<%= link_to "remove", '#', class: "remove_fields btn btn-warning row_spacer" %>
</div>
<div class="row_spacer"></div>
</div>
application_helper.rb
def link_to_add_fields(name, f, type)
new_object = f.object.send "build_#{type}"
id = "new_#{type}"
fields = f.send("#{type}_fields", new_object, child_index: id) do |builder|
render(type.to_s + "_fields", f: builder)
end
link_to(name, '#', class: "add_fields btn btn-primary form-group", data: {id: id, fields: fields.gsub("\n", "")})
end
application.css.scss
.row_spacer {
margin-top: 5px;
}
now it is pretty. Probably won't work for everyone but it sucked trying to figure this out when you are still learning.
So according to comments on this pull request
https://github.com/texticle/texticle/pull/25
Texticle is now called Textacular.
https://github.com/textacular/textacular
Thank you this was very helpful
Thank you!
haha, didn't restart the server
happy! but feeling slightly stupid
Oh man, I got so pumped watching his but can't get it to work. Install the gemfile under development
group :development do
gem 'better_errors'
gem 'binding_of_caller'
end
bundle install
bundle update
fire up my app, get to an error, and just the same usual error screen as always.
Running Rails 4 on Ubuntu with Sublime Text 3. Any ideas?
I saw that this is mainly a Mac gemfile but thought that was just for the linking between the error screen and the text editor...
sad.