This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Company < ActiveRecord::Base | |
has_many :addresses | |
end | |
class Address < ActiveRecord::Base | |
belongs_to :company | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Company < ActiveRecord::Base | |
has_many :addresses | |
accepts_nested_attributes_for :addresses, :allow_destroy => true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% form_for setup_company(@company) do |f| %> | |
<%= f.label :name %><br /> | |
<%= f.text_field :name %><br /> | |
<% f.fields_for :addresses do |address_form| %> | |
<%= f.label :street %><br /> | |
<%= address_form.text_field :street %><br /> | |
<%= f.label :city %><br /> | |
<%= address_form.text_field :city %><br /> | |
<%= f.label :post_code %><br /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def setup_company(company) | |
returning(company) do |c| | |
c.addresses.build if c.addresses.empty? | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ObserveForm = Class.create({ | |
initialize: function() { | |
this.form = $('form_id'); | |
this.form.observe('submit', this.submitForm.bindAsEventListener(this)); | |
this.data_area = $('display_area'); | |
}, | |
submitForm: function(event) { | |
event.stop(); | |
this.form.request({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Company < ActiveRecord::Base | |
# Sunspot/Solr search indexing | |
searchable do | |
string :name | |
text :profile | |
integer :media_type_id | |
integer :sector_type_id, :multiple => true do | |
sectors.map {|sector| sector.sector_type_id} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Your results</h2> | |
<% unless @results.nil? %> | |
<table> | |
<tr> | |
<th>company</th> | |
<th>profile</th> | |
</tr> | |
<% for result_item in @results %> | |
<tr class="<%= cycle('odd', 'even') %>"> | |
<td><%= result_item.name %></td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def search_results | |
search = Company.search do | |
keywords 'belfast marketing' | |
with(:sector_type_id).any_of [1, 2, 4, 8] | |
paginate :page => page_number, :per_page => 30 | |
order_by :name, :asc | |
end | |
@results = search.results | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
common: &common | |
solr: | |
hostname: localhost | |
port: 8983 | |
production: | |
<<: *common | |
solr: | |
path: /data/solr/myapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ***** Raindrop Theme | |
!base_color_1 = #1C1D21 | |
!base_color_2 = #31353D | |
!base_color_1_light = !base_color_1 + #212121 | |
!base_color_1_lighter = !base_color_1 + #444444 | |
!base_color_1_dark = !base_color_1 - #111111 | |
!base_color_2_light = !base_color_2 + #212121 | |
!base_color_2_lighter = !base_color_2 + #444444 |