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_tag( '/search', :method => 'get' ) do %> | |
<%= text_field_tag :search_str %> | |
<%= submit_tag "Search", :name => nil %> | |
<% 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
# Setting up a polymorphic factory for a join table | |
# Since rosterable is not the default name of the model we are calling, we can't use the convenience method | |
# that is used for area (f.association) | |
# All we have to do is fall back to the block way of doing it, calling f.rosterable and passing in the | |
# object you want to populate it with ( in this case a template). This will fill in both rosterable_id | |
# and rosterable_type for us | |
Factory.define(:template_rostered_area, :class => RosteredArea) do |f| | |
f.association :area | |
f.rosterable { |a| a.association(:template)} |
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
//Use this to align the text in a text view where you want it | |
textView.contentInset = UIEdgeInsetsMake(-8,-8,0,0); |
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
//How to add a spinner onto a button | |
- (IBAction)deleteAction:(id)sender { | |
[self.navigationController.view addSubview:activityIndicator]; | |
[activityIndicator startAnimating]; | |
// Spinner won't start spinning until we finish processing this event, so | |
// we're just going to schedule the rest of what we need to do. | |
// doDelete: will run when the main thread gets its next event. |
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
CGSize dyn_size = [title sizeWithFont:self.font]; | |
CGRect frame = self.frame; | |
frame.size.width = dyn_size.width; | |
self.frame = frame; |
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
# Dynamically define whether a user has a role methods in a nice query language based on User::ROLES | |
# Eg. Can now call user.admin? or user.billing? | |
ROLES.each do |role| | |
method_name = (role + '?').to_sym | |
send :define_method, method_name do | |
self.role == role | |
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
#!/usr/bin/env ruby | |
require 'highline/import' | |
require 'sofa' | |
class NoMatchFoundError < StandardError; end; | |
class EpisodeFile | |
attr_accessor :file, :season, :episode, :extension, :high_def, :valid |
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
# Using formtastic but can easily converted to use standard rails form helpers | |
= semantic_form_for [ @user ] do |f| | |
= f.semantic_fields_for :user_specialities do |user_speciality| | |
= user_speciality.inputs do | |
= user_speciality.input :speciality_id, :as => :hidden | |
= user_speciality.input :_destroy, :label => user_speciality.object.speciality.name, :as => :boolean, :checked_value => 0, :unchecked_value => 1, :input_html => { checked: !user_speciality.object.new_record? } |
OlderNewer