I have a nested resource appointments in profiles in route.rb.
resources :profiles, only: [:show, :update, :edit] do
resources :appointments
end
In my AppointmentsController.rb I write new method like this
def new
#appointment = Appointment.new
end
I have form for this new method in appointments/new.html.erb
<section class="login-page border-top-blue padding-v-10">
<section class="login-details-div bg-light-grey">
<%= form_for(#appointment, :html => { :class => 'form-horizontal login-form-container login-form-div' }) do |f| %>
<h1>Create New Appointments</h1>
<div class="form-div-send-for-inlinement-icon-with-text-field">
<span class="form-wrapper ">
<i class="fa fa-user login-icon-white login-icon-envelop "></i>
</span>
<div class="label-input-div input-width">
<label for="" class="login-label-div"></label>
<div class="form-wrapper"><%= f.text_area :description, class:'login-icon-white', autofocus: true %></div>
</div>
</div>
<div class="form-div-send-for-inlinement-icon-with-text-field">
<span class="form-wrapper ">
<i class="fa fa-envelope login-icon-white login-icon-envelop "></i>
</span>
<div class="label-input-div input-width">
<label for="" class="login-label-div">topic</label>
<div class="form-wrapper"><%= f.text_field :topic, class:'login-icon-white' %></div>
</div>
</div>
<div class="form-div-send-for-inlinement-icon-with-text-field">
<span class="form-wrapper ">
<i class="fa fa-envelope login-icon-white login-icon-envelop "></i>
</span>
<div class="label-input-div input-width">
<label for="" class="login-label-div">Appointment Date</label>
<div class="form-wrapper"><%= f.date_field :appointment_date, class:'login-icon-white' %></div>
</div>
</div>
<div class="form-div-send-for-inlinement-icon-with-text-field">
<span class="form-wrapper ">
<i class="fa fa-envelope login-icon-white login-icon-envelop "></i>
</span>
<div class="label-input-div input-width">
<label for="" class="login-label-div">class hours</label>
<div class="form-wrapper"><%= f.number_field :class_hours, class:'login-icon-white' %></div>
</div>
</div>
<div class="form-group">
<label for="" class="col-sm-offset-2 col-sm-10 col-xs-offset-2 col-xs-10 col-md-offset-1 col-md-11 login-btn-div">
<%= f.submit "submit", :class => "login-btn" %>
</label>
<label for="" class="col-sm-offset-2 col-sm-10 col-xs-offset-2 col-xs-10 col-md-offset-1 col-md-11 login-btn-div">
<%= link_to "Cancel", root_path(), :class => "login-btn" %>
</label>
</div>
<% end %>
</section>
</section>
I have a link tag in profiles/show.html.erb for callling this new method of AppointmentsController.rb .
<%= link_to "book a class", new_profile_appointment_path, class: 'btn-green2' %>
I don't understand why whenever I click this link I got link in url
http://localhost:3000/profiles/3/appointments/new
which is I need.But there is an error
undefined method 'appointments_path' for #<#<Class:0x007f24ccc16bf8>:0x007f24ccc154b0>
I could not figure out my fault here.Please help.
As you are using nested resources for creating every appointment you need a profile under which your appointment will be nested. So you need to pass profile_id under which your appointment will be created as your path new_profile_appointment_path is also saying.
<%= form_for([#profile, #appointment], :html => { :class => 'form-horizontal login-form-container login-form-div' }) do |f| %>
You also need to define #profile in your method.
def new
#profile = Profile.find(params[:profile_id])
#appointment = Appointment.new
end
Url in your form should be smth like this:
<%= form_for [#profile, #appointment] do |f| %>
...
<% end %>
form_for tries to use existing paths. You don't have an appointments_path but you do have an profile_appointments_path
To use that path, just pass both objects to the form_for
<%= form_for([#profile, #appointment], :html => { :class => 'form-horizontal login-form-container login-form-div' }) do |f| %>
However, this does mean you need to create an instance variable #profile in your new method...
def new
#profile = Profile.find(params[:profile_id])
#appointment = Appointment.new
end
Related
I'm trying to do an edit object in Ruby on Rails using a modal form, when I try to do the link_to edit_plane_path(plane) in planes.html.erb I get the following error:
undefined local variable or method `plane' for #<#:0xd580e98>
Did you mean? #plane
plane_url
#planes
However, trying any of those doesn't really change the fact that I still get an error on the page and I can't even load it.
planes.html.erb
<table>
<thead>
<tr>
<th>Image</th>
<th>Operating agency</th>
<th>Date</th>
<th>Call sign</th>
<th>Country</th>
<th>Info</th>
<th>Action</th>
</tr>
<thead>
<tbody>
<% #planes.each do |p| %>
<tr class="gradeC">
<td>
<%= image_tag(p.image, size: "150x150")%></td>
<td class="w-25"><%= p.provider%>
</td>
<td><%= p.brand%></td>
<td class="center"><%= p.year%></td>
<td class="center"><%= p.call_sign%></td>
<td><%= p.country%></td>
<td><%= p.info%></td>
<td class="text-right">
<div class="btn-group">
<%= link_to 'Edit', edit_plane_path(plane), remote: true, :class =>'btn white btn btn-xs' %>
<button class="btn-white btn btn-xs">Delete</button>
</div>
</td>
</tr>
</tbody>
<% end %>
</table>
_form.html.erb
<!-- FORM EDIT -->
<div id="edit-plane" class="modal fade" aria-hidden="true">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-body">
<div class="row">
<div class="col-sm-12"><h3 class="m-t-none m-b">Edit plane</h3>
</div>
</div>
<%= form_for #plane, url: planes_path, remote: true do |f| %>
<div class="form-group row">
<div class="col-sm-6">
<label>Brand</label>
<%= f.text_field :brand, class:"form-control"%>
</div>
<div class="col-sm-5">
<label>Model</label>
<%= f.text_field :model, class:"form-control"%>
</div>
</div>
<div class="form-group row">
<div class="col-sm-5">
<label>Year</label>
<%= select_tag :hyear, options_for_select(["2015","2016","2017","2018","2019"], "2019"), class:"select2_demo_1 form-control" %>
<%= f.hidden_field :year %>
</div>
<div class="col-sm-6">
<label>Country</label>
<%= select_tag :hcountry, nil, class:"select2_demo_1 form-control" %>
<%= f.hidden_field :country %>
</div>
<script language="javascript">
populateCountries("hcountry");
</script>
</div>
<div class="form-group row">
<div class="col-sm-6">
<label>Provider</label>
<%= select_tag :hprovider, options_for_select([ "Test", "Test2"], "Test"), class:"select2_demo_1 form-control"%></select>
<%= f.hidden_field :provider %>
</div>
<div class="col-sm-5">
<label>Tactical call sign</label>
<%= f.text_field :call_sign, class:"form-control"%>
</div>
</div>
<div class="form-group row">
<div class="col-sm-6">
<label>Extra info</label>
<%= f.text_area :info %>
</div>
<div class="col-sm-5">
<label>Image</label>
<%= f.file_field :image %>
</div>
</div>
<!-- SUBMIT -->
<button class="btn btn-primary btn-lg float-right ml-2" id="cancelbtn">Cancel</button>
<%= f.submit "Submit", id:"edpla", class: 'btn btn-primary btn-lg float-right'%>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>
edit.js.erb
// Add the dialog title
$('#edit-plane h3').html("<i class=' glyphicon glyphicon-pencil'></i> Edit Plane");
// Render the edit form
$('.modal-body').html('<%= j render("form") %>');
// Show the dynamic dialog
$('#edit-plane').modal("show");
// Set focus to the first element
$('#edit-plane').on('shown.bs.modal', function () {
$('.first_input').focus()
})
update.js.erb
$('#edit-plane').modal('toggle');
$('#customer_<%= #plane.id %>').replaceWith('<%= j render (#plane) %>')
planes_controller.rb
class PlanesController < ApplicationController
def planes
#plane = Plane.new
#planes = Plane.all
end
def create
#plane = Plane.new(plane_params)
if #plane.save
flash[:success] = "Plane successfully added"
redirect_to :planes => 'post', :action => 'planes'
else
flash[:error] = "Something went wrong"
render 'planes'
end
end
def edit
#plane = Plane.find(params[:id])
end
def update
respond_to do |format|
if #plane.update(plane_params)
format.json { head :no_content }
format.js
else
format.json { render json: #customer.errors.full_messages, status: :unprocessable_entity }
end
end
end
private
def plane_params
params.require(:plane).permit(:brand, :model, :provider, :call_sign, :user, :country, :image, :info, :year)
end
end
My goal is to edit a plane in the table through a modal form, but I can't even show the page at the moment.
Here:
<% #planes.each do |p| %>
...you are passing each plane as p. Therefore, try:
<%= link_to 'Edit', edit_plane_path(p), remote: true, class: 'btn white btn btn-xs' %>
Here is what happens
Here is my views code
Form
<%= simple_form_for([:supplier, #fuel_price],remote: true, :html => {:class => 'form-vertical' }) do |f| %>
<%= f.simple_fields_for :fuel_products do |fuel_products_form| %>
<div class="field">
<%= render partial: 'fuel_products_fields', locals: {f: fuel_products_form} %>
</div>
<% end %>
<%= link_to_add_fields "Add more", f, :fuel_products %>
<div class="modal-footer">
<%= f.button :submit, "Update", class: "btn btn-success"%>
</div>
<%end%>
Fuel Products Field Partial
<div class="col-md-6">
<%= f.input :fuel, label: "Fuel Type", :collection => fuel_types, class: "form-control select",:selected => "87 RFG" %>
</div>
<div class="col-md-3">
<%= f.input :price, class: "form-control", placeholder: "$1.25" %>
</div>
<%= f.hidden_field :_destroy %>
<ul class="list-unstyled">
<li><%= link_to '#', class: "btn btn-danger btn-xs remove_fields" do %>
Remove
<%end%></li>
</ul>
Javascript code
ready = ->
$('#FuelmodelBody').on 'click', '.remove_fields', (event) ->
$(this).prev('input[type=hidden]').val('1')
$(this).closest('.field').hide()
event.preventDefault()
$('#FuelmodelBody').on 'click', '.add_fields', (event) ->
console.log('It is really happening ....')
time = new Date().getTime()
regexp = new RegExp($(this).data('id'), 'g')
$(this).before($(this).data('fields').replace(regexp, time))
event.preventDefault()
$(document).ready(ready)
$(document).on('page:load', ready)
Views Modal code
<div class="modal inmodal" id="newFuelPrice" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated bounceInRight">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">×</span>
<span class="sr-only">Close</span>
</button>
<i class="fa fa-usd modal-icon" style="color:#1ab394"></i>
<h4 class="modal-title">Add New Fuel Price</h4>
<span class="font-bold">Your contacts will get text message of your latest price</span>
</br>
<span class="font-bold">As (your fuel price + the formula).</span>
</div>
<div class="modal-body" id="FuelmodelBody">
<!-- form -->
</div>
</div>
</div>
</div>
I also have a helper function for link_to_add_fields
def link_to_add_fields(name, f, association)
# creates a new instance of the 'has_many' object
new_object = f.object.send(association).klass.new
# new_object = f.object.association.klass.new
# f.object.association.klass # => Document
# new_object = f.object.documents.build Document(user_id: f.object.id)
# gets the object id
id = new_object.object_id
# creates a new form for the association
fields = f.fields_for(association, new_object, child_index: id) do |builder|
render(association.to_s + '_fields', f: builder)
end
link_to(name, '#', class: 'add_fields', data: { id: id, fields: fields.delete("\n") })
end
Moving around code since morning and still could not figure out how to fix those buttons by aligning side by add, the add more will also be button in blue, i was just playing around and converted it to link. I am Using simple Form
If you want to align your "Remove" buttons with their corresponding Fuel type and Price fields, then you need to put them all in a single Bootstrap row like so:
<div class="row">
<div class="col-md-6">
<%= f.input :fuel, label: "Fuel Type", :collection => fuel_types, class: "form-control select",:selected => "87 RFG" %>
</div>
<div class="col-md-3">
<%= f.input :price, class: "form-control", placeholder: "$1.25" %>
</div>
<div class="col-md-3">
<%= f.hidden_field :_destroy %>
<ul class="list-unstyled">
<li><%= link_to '#', class: "btn btn-danger btn-xs remove_fields" do %>
Remove
<%end%></li>
</ul>
</div>
</div>
Also, you probably don't need that extra ul tag. It does not carry any additional meaning, since you have just one button in there. It is not a list.
<div class="row">
<div class="col-md-6">
<%= f.input :fuel, label: "Fuel Type", :collection => fuel_types, class: "form-control select",:selected => "87 RFG" %>
</div>
<div class="col-md-3">
<%= f.input :price, class: "form-control", placeholder: "$1.25" %>
</div>
<div class="col-md-3">
<%= f.hidden_field :_destroy %>
<%= link_to 'Remove', '#', class: "btn btn-danger btn-xs remove_fields" %>
</div>
</div>
I have a ruby form with a text box for start_date and one for end date. I need to add a dropdown for status. I added the select_tag and it populates correctly. My problem is how do I get the value that was selected?
Snippet from form:
<div class="modal-body">
<div class="control-group">
<label class="control-label">From</label>
<div class="controls">
<%= text_field_tag "purchase_requests_from_time", Date.today.beginning_of_month, :class => "text date_picker report_start_time_picker" %>
</div>
</div>
<div class="control-group">
<label class="control-label">To</label>
<div class="controls">
<%= text_field_tag "purchase_requests_to_time", Date.today.end_of_month, :class => "text date_picker report_start_time_picker" %>
</div>
</div>
<div class="control-group">
<label class="control-label">Status</label>
<div class="controls">
<%= select_tag :status, options_for_select(get_purchase_request_statuses) %>
</div>
</div>
<div class="control-group">
<label class="control-label">Status2</label>
<div class="controls">
<%= select_tag "status2", options_for_select(get_purchase_request_statuses) %>
</div>
</div>
</div>
Then when I try to access the params in the controller
from_time = params[:purchase_requests_from_time]
to_time = params[:purchase_requests_to_time]
status = params[:status]
status2 = params[:status2]
The time parameters show up fine, the status and status2 parameters are missing.
params = {ActiveSupport::HashWithIndifferentAccess} ActiveSupport::HashWithIndifferentAccess (4 elements)
'purchase_requests_from_time' = "Tue Mar 01, 2016"
'purchase_requests_to_time' = "Thu Mar 31, 2016"
'action' = "export"
'controller' = "purchase_requests"
Any idea what I am doing wrong?
I found my problem. I was missing the form_tag and was using a link_to rather than a submit_tag. This is the code that works
<div class="modal hide" id="download_purchase_requests">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Download Purchase Requests</h3>
</div>
<%= form_tag({:action => :export, :controller => :purchase_requests}, :multipart => true) do %>
<div class="modal-body">
<div class="control-group">
<label class="control-label">From</label>
<div class="controls">
<%= text_field_tag "purchase_requests_from_time", Date.today.beginning_of_month, :class => "text date_picker report_start_time_picker" %>
</div>
</div>
<div class="control-group">
<label class="control-label">To</label>
<div class="controls">
<%= text_field_tag "purchase_requests_to_time", Date.today.end_of_month, :class => "text date_picker report_start_time_picker" %>
</div>
</div>
<div class="control-group">
<label class="control-label">Status</label>
<div class="controls">
<%= select_tag :purchase_request_status, options_for_select(get_purchase_request_statuses, :selected => params[:purchase_request_status]) %>
</div>
</div>
</div>
<div class="modal-footer">
Close
<%= submit_tag "Download", :class => "btn", :id => "download-btn", :onsubmit => "$('#download-btn').attr('disabled', 'disabled');" %>
</div>
<% end %>
</div>
<%= form_tag({controller: "cc_banker_assignments", action: "index"}, method: "get", class: "form-horizontal") do %>
<div class="col-md-4">
<span class="badge badge-error count-error"></span>
<div class="form-group">
<label for="" class="col-sm-4 control-label">Date of Assignment</label>
<div class="col-sm-7">
<%= text_field_tag "assignment_date", params[:assignment_date], class: "form-control", id: "date-range" %>
</div>
</div>
<div class="form-group" style="margin-bottom: 1.5em;">
<label for="" class="col-sm-4 control-label">Assigned To</label>
<div class="col-sm-7">
<%= select_tag "assigned_to", options_from_collection_for_select(#banker, :id, :name, params[:assigned_to]), class: 'form-control single-select', prompt: "All Bankers" %>
</div>
</div>
<div class="col-sm-8 pull-right" style="margin-top: -0.3em">
<%= submit_tag "Search", :class => "btn btn-default lender-search-btn btn-s-layout" %>
<%= button_tag "Clear", :type => 'reset', :class => "btn btn-primary btn-c-layout clear_button", :onClick => "check_for_cancel" %>
</div>
</div>
</div>
<% end %>
Ok so i have this form and i want to be able to pass a variable to my index method on my controller when i click on the button.
This is because i want my controller to know if the clear button has been clicked and the only way for me to do tht is to pass a variable to my controller index method.
my controller method
def index
#banker = Banker.where("locked_at is null and approved = true").order('name asc')
ap params
if !params[:get_status].nil?
params[:banker_status] = BankerAssignmentStatus.where("assignment_status =? ",params[:get_status]).pluck(:id)
end
search_banker_assignment params
render template: 'cc_banker_assignments/index'
end
How do i do this using rails
Are you trying to clear the form inputs by requesting index page? You can use link_to instead of button_tag to do that, or just javascript. If you really want to pass a variable to the controller, you can bind your button to a jQuery.ajax() call.
I'm working on an assignment for a course I'm doing on refactoring some version of the typo blog. I need to add a new form to a page in order to get some information, the problem is that the submit button is not responding and the form is also badly alligned. http://i.imgur.com/5HKMG0L.png
I don't have a good understanding of front-end, so this app is quite confusing for me but this is the way the page is rendered:
**first view that gets called:**
<% #page_heading = _('New article') %>
<%= render "admin/shared/edit", { :form_type => "article", :form_action => { :action => "new", :id => #article.id , :class => ('autosave')} } %>
**admin/shared/edit:**
<% className = form_action.delete(:class) %>
<%= form_tag(form_action, :id => "#{form_type}_form", :enctype => "multipart/form-data", :class => className) do %>
<%= render :partial => "form" %>
<% end %>
[CODE I ADDED TO CREATE A NEW FORM]
***<h3> Merge Articles </h3>
<div class='clearfix'>
<%= form_tag(categories_path, :class => className) do %>
<%= label :article, :merge_with, 'Article ID' %>
<%= text_field :merge_with , '', {:class => 'span1'}%>
<% end %>
<%= submit_tag 'Merge' %>
</div>***
**_form.html.erb:**
<input type="hidden" name="current_editor" id="current_editor" value="<%= current_user.editor %>" />
<input type="hidden" name="user_textfilter" id="user_textfilter" value="<%= current_user.text_filter_name %>" />
<div id="autosave"></div>
<div id="article_keywords_auto_complete" class="auto_complete"></div>
<%= error_messages_for 'article' %>
<div class='editor-right'>
<div class='well'>
<h4><%= _("Publish settings") %></h4>
<div class='actions'>
<%= link_to_destroy_with_profiles(#article) unless #article.id.nil? or #article.state.to_s.downcase == 'draft' %>
<span id='destroy_link'><%= link_to_destroy_draft #article %></span>
<span id='preview_link'><%= link_to(_("Preview"), {:controller => '/articles', :action => 'preview', :id => #article.id}, {:target => 'new', :class => 'btn info'}) if #article.id %></span>
</div>
<div class='clearfix'>
<%= _("Status:") %> <strong><%= #article.state.to_s.downcase %></strong> Change
<ul class='inputs-list'>
<li id='status' style='display: none;'>
<label for="article_published">
<%= check_box 'article', 'published' %>
<%= _("Published") %>
</label>
</li>
</ul>
</div>
<div class='clearfix'>
Comments are <strong>enabled</strong> and trackbacks are <strong>disabled</strong> Change
<ul class='inputs-list' id='conversation' style='display: none'>
<li>
<label for="article_allow_pings">
<%= check_box 'article', 'allow_pings' %>
<%= _("Allow trackbacks") %>
</label>
</li>
<li>
<label for="article_allow_comments">
<%= check_box 'article', 'allow_comments' %>
<%= _("Allow comments") %>
</label>
</li>
</ul>
</div>
<div class='clearfix'>
<%= _("Publish <strong>now</strong>") %> Change
<ul class='inputs-list'>
<li id='publish' style='display: none;'>
<%= calendar_date_select 'article', 'published_at', {:class => 'span3'} %>
</li>
</ul>
</div>
<div class='clearfix'>
<%= _("Visibility:") %> <strong>public</strong> Change
<ul class='inputs-list' id='visibility' style='display: none'>
<li>
<label for="article_password"><%= _("Password:") %>
<%= password_field :article, :password, :class => 'span3' %>
</label>
</li>
</ul>
</div>
<div class='clearfix'>
<%= _("Permalink:") %> Change
<ul class='inputs-list' id='permalink' style='display: none'>
<li>
<%= text_field 'article', 'permalink', {:class => 'span4'} %>
</li>
</ul>
</div>
<div class='clearfix'>
<%= _("Article filter") %>: <strong><%= #article.text_filter.description %></strong> Change
<ul id='text_filter' class='inputs-list' style='display: none'>
<li>
<select name="article[text_filter]" id="text_filter">
<%= options_for_select text_filter_options, #article.text_filter %>
</select>
</li>
</ul>
</div>
<div class='actions'>
<input id='save_draft' type="submit" value="<%= _('Save as draft') %>" name="article[draft]" class='btn info' />
<%= save( _("Publish")) %>
</div>
</div>
<div class='well'>
<h4><%= _("Categories") %></h4>
<%= render 'categories' %>
</div>
<%= get_post_types %>
</div>
<div class='editor-left'>
<div>
<div>
<%= text_field 'article', 'title', :class => 'span1', :style => ' width: 99%', :placeholder => _('Title') %>
</div>
<%= render('images', { :images => #images}) unless #images.empty? %>
<div id='editor-menu'>
<ul class="tabs">
<li id="f" class='<%= "active" if current_user.editor == 'visual' %>'>
<%= build_editor_link("Visual", 'insert_editor', 'fck', 'visual_editor', 'visual') %>
</li>
<li id="s" class='<%= "active" if current_user.editor == 'simple' %> '>
<%= build_editor_link("HTML", 'insert_editor', 'simple', 'simple_editor', 'simple') %>
</li>
</ul>
</div>
<div id="editor">
<div id='quicktags' style='<%= "display: none;" if current_user.editor == 'visual' %>'>
<script type="text/javascript">edToolbar('article_body_and_extended');</script>
</div>
<div id ='visual_editor' <%= "style='display: none;'" if current_user.editor == 'simple'%> >
<%= ckeditor_textarea('article', 'body_and_extended', {:class => 'large', :height => '300px', :rows => '20'}) if current_user.editor == 'visual' %>
</div>
<div id='simple_editor' class='input_text' <%= "style='display: none;'" if current_user.editor == 'visual'%> >
<%= text_area('article', 'body_and_extended', {:class => 'large', :height => '300px', :rows => '20'}) if current_user.editor == 'simple' %>
<%= render_macros(#macros) if current_user.editor == 'simple' %>
</div>
</div>
<h4><%= _("Tags") %></h4>
<div class='class'>
<%= text_field 'article', 'keywords', {:autocomplete => 'off', :style => 'width: 100%'} %>
</div>
<%= auto_complete_field 'article_keywords', { :url => { :action => "auto_complete_for_article_keywords"}, :tokens => ','}%>
</div>
<div class='separator'>
<h4><%= _("Excerpt") %></h4>
<div class=''>
<%= text_area 'article', 'excerpt', {:height => '150', :style => 'width: 100%', :rows => '5'} %>
<span class='help-block'><%=_("Excerpts are posts summaries that are shown on your blog homepage only but won’t appear on the post itself") %></span>
</div>
</div>
<div class=''>
<h4><%= _("Uploads") %></h4>
<p class='help-block'>Uploads will be displayed as attachments in your RSS feed, but won't appear in your articles.</p>
<ul id='attachments' class='inputs-list'>
<%= render 'admin/content/attachment', { :attachment_num => 1, :hidden => false } -%>
</ul>
</div>
</div>
</div>
Any help would be really appreciated. Thanks.
You need to use CSS to align your form to the left. The best way to do this is going into app/assets/articles.css (or any of your CSS files) and adding this line:
.left { text-align: left; }
Then go back into your views and assign anything you want to align to the left the "left" class, for example in your form you can wrap the relevant portions in a div to make everything align left:
<div class="left">
<%= form_tag(categories_path, :class => className) do %>
<%= label :article, :merge_with, 'Article ID' %>
<%= text_field :merge_with , '', {:class => 'span1'}%>
<% end %>
<%= submit_tag 'Merge' %>
</div>