Bootstrap select menu styling not combining with ruby - ruby

I have the following bit of code, I am trying to insert my ruby code into the select to create the standard drop-down selection. The code works however the styling it really shit.
<%= form.label :housing_size %>
<div class="field form-control form-group form-select pb-1">
<%= form.select :housing_size_id, options_from_collection_for_select(Housingsize.order(:value).all, "id", "value", current_user.id) %>
</div>
<p class=" open-text pt-1"> Please select a housing size </p>
image of styling issue i have

Related

Multiple Choice in Transformation

Trying to add multiple choice category in a transformation. If there are multiple categories, I need to show them inline, separately, not run together (see second listing in image url). I was able to remove the |, but it does not list them separately.
Here is my code:
<div id="NewsFeed">
<div class="newsbox">
<%# IfEmpty(Eval("Category"), "", "<span class='category'>" + Eval("Category").ToString().Replace("|"," ") + "</span>") %>
<div class="newslist-item">
<h4 class="news-title"><%# Eval("NewsTitle") %></h4>
<p class="news-date"> <%# GetDateTime("NewsReleaseDate", "MM/dd/yyyy") %></p>
<p class="news-summary"><%# Eval("NewsSummary") %> </p>
<p class="readmore">Read More
</div>
</div>
</div>

how to "Each do |article|" but after every n-articles it has to start in a new row(foundation)

I got this Rails blogs app and for the indexpage where the articles are posted it shows a short version of the article.
<%= render 'layouts/header' %>
<%= render 'layouts/topbar' %>
<div class="contentnews">
<%= render 'layouts/bannerad' %>
<div class="row">
<% if current_user.try(:admin?) %>
<%= link_to 'Nieuws toevoegen', new_article_path, :class => "button ala" %>
<% end %>
</div>
<div class="row">
<%= render 'overview' %>
</div>
</div>
The overview-partial :
<div class="articlebox ">
<div class="large-4 columns">
<% #articles.reverse_each do |article| %>
<div class="articlebox2">
<div class="articleindex">
<%= link_to article.title, article %>
</div>
<div class="articlebody">
<%= article.short.to_s.html_safe %>
</div>
</div>
<% end %>
</div>
</div>
The problem is that this way all the articles end up in one row. I want it to show the short articles inline on the page and after every two or three article it has to start in a new row with again two or three short articles.
Anybody got any idea?
You don't actually need to create a row every n-elements. With foundation just wrap all the elements in a row, and give them columns class:
<div class="articlebox">
<div class="large-4 columns">
<div class="row"> <!-- Wrap in a row -->
<% #articles.reverse_each do |article| %>
<div class="articlebox2 large-6 columns"> <!-- Give a column and width class here -->
...
</div>
<% end %>
</div>
So you can nesting grids with foundation, and creating new rows is not necessary, foundation will just wrap if the elements exceeds the grid.
If you actually really want to create rows, you can have a look at the method each_with_index API and then insert row elements if index % 2 == 0. But this is unnecessary complexity.

Adding a bootstrap glyphicon to a button in rails

I would like to add a user glyphicon to my login input box in a rails app i am currently using Rails 4.2.3 and Ruby 2.2.0
I have tried to search this for quite some time but have not found how to add this to a rails app and would like my code to remain ruby as much as possible and if at all possible (if not i suppose html will suffice but i would LOVE to learn how to do this in rails syntax.
any help would be appreciated.
my input field looks like this so far.
<div class="input-group input-group-lg">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
I would aslo like the glyph to appear on the Left and the placeholder on the Right of the input box if possible.
<%= button_tag raw("<i class='srch-control-icon-srch'></i> search"), class: "button round" %>
HTML
<div>
<div class="input-group">
<input type="text" class="form-control" placeholder="username" aria-describedby="basic-addon2"> <span class="input-group-addon" id="basic-addon2"> <span class="glyphicon glyphicon-log-out">
</span></span>
</div>
</div>
Fiddle Here

Values are not showing using Rails 3

I want to display data inside text field and those values will be fetched dynamically.But i am not getting any value(only blank filed is coming) when show action is executing.
Please check mu code given below.
Views/posts/show.html.erb
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<input type="text",value="<%= #post.name %>">
</p>
<p>
<b>Title:</b>
<input type="text",value="<%= #post.title %>">
</p>
<p>
<b>Content:</b>
<input type="text",value="<%= #post.content %>">
</p>
<%= link_to 'Edit', edit_post_path(#post) %> |
<%= link_to 'Back', posts_path %>
Please help me to resolve this issue.
Replace the value Property by removing quotes as:
<input type="text",value=<%= #post.content %>>

Accessing data from DB according to drop down selection using Rails 3

I have one doubt.I have a form which has two drop down field.when user will select option from first drop down list,accordingly all required value will fetch from db and set in second drop down list.Check my below code.
views/payments/payment.html.erb:
<div class="tbpaddingdiv2">
<%= form_for :payment,:url => {:action => "check_type" },remote: true do |f| %>
<div class="totalaligndiv">
<div class="input-group bmargindiv1 col-md-6 pull-left"><span class="input-group-addon text-left"><div class="leftsidetextwidth">Type :</div></span>
<%= f.select(:s_catagory,options_for_select([['Wood','Wood'],['Puja Samagree','Puja Samagree'],['Sweeper','Sweeper'],['Photo Grapher','Photo Grapher'],['Burning Assistant','Burning Assistant']],selected: "Type"),{},{:class => 'form-control'},{:onchange => ''}) %>
</div>
<div class="input-group bmargindiv1 col-md-6 pull-left"><span class="input-group-addon text-left"><div class="leftsidetextwidth">Select Vendor :</div></span>
<select class="form-control">
<option selected>Selected Vendor</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</div>
<div class="clearfix"></div>
<div class="tbpaddingdiv1 text-center">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
<% end %>
</div>
controller/payments_controller.rb:
class PaymentsController < ApplicationController
def payment
#payment=Vendor.new
end
def check_type
#vendor=Vendor.find_by_s_catagory(params[:s_catagory])
end
end
Check my view page.There are two drop down menu.I can not complete this.First user will select value from first drop down menu.As soon as value will selected the data base search operation will start and all required value will fetched.The retrieved value will set in second drop down list.After that submit button will be clicked for other purpose.I am using Rails version 3.2.19.Please help me.
change your view, assign some class to vendor select div like:
.vendor_partial
= render partial: "select_vendors"
on select of s_catagory you will send ajax request to check_type and render returned #vendor in div for selected vendors,
in your check_type.js.haml file:
(".vendor_partial").html("#{escape_javascript(render partial: "select_vendors")}")
and _select_vendors.html.haml :
= collection_select(:vendor, :id, (#vendor.nil? ? [] : #vendor), :id, :vendor_name, prompt: "Select vendor")

Resources