Skip to content

Instantly share code, notes, and snippets.

View JonasNielsen's full-sized avatar

Jonas Bylov JonasNielsen

View GitHub Profile
<% form_for @person, :url => { :action => "update" } do |person_form| %>
...
<% @person.projects.each do |project| %>
<% if project.active? %>
<% person_form.fields_for :projects, project do |project_fields| %>
Name: <%= project_fields.text_field :name %>
<% end %>
<% end %>
<% end %>
<% end %>
puts 'What\'s on your mind, son?'
question = gets.chomp
while question != question.upcase
puts 'WHAT?! SPEAK UP SON!'
question = gets.chomp
if question == question.upcase
millenium = 1930
year = millenium + rand(20)
puts 'NO, NOT SINCE '+ year.to_s + '!'
end
class UserSessionsController < ApplicationController
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Successfully logged in."
redirect_to root_url
puts 'Enter a starting year:'
startingyear= gets.chomp
puts 'Starting year is now ' + startingyear
puts 'Now enter an ending year'
endingyear = gets.chomp
puts 'Ending year is now ' + endingyear
startingyear.to_i.upto(endingyear.to_i) do |i|
if(i % 4 == 0 AND i % 100 != 0)
puts i
class Designer < ActiveRecord::Base
has_one :login, :as => :user, :dependent => :destroy
accepts_nested_attributes_for :login
end
class User < ActiveRecord::Base
belongs_to :userable, :polymorphic => true
end
class Designer < ActiveRecord::Base
has_one :user_login, :as => :userable
accepts_nested_attributes_for :user_login
end
class DesignersController < ApplicationController
respond_to do |format|
format.html { do_your_counting here }
end
# IN RJS
page.replace_html "client_informations", :partial => 'shared/client_billing_form', :locals => {:client => @client}
# IN _client_billing_form
%p
= remote_form_for client, :controller => 'clients', :action =>'update_billing_from_editor', :id => client.id, :method => :put do |f|
= render :partial => 'shared/client_billing_info_fields', :locals => {:f => f, :client => client}
%br
= f.submit "Correct Informations", :class => "button green"
- if client.is_company?
- hide = ""
- else
- hide = "hidden"
#company_information{:class => "#{hide}"}
%div
%br/
= f.label :company_name
%br/
def waiting?
if status == "waiting"
true
else
false
end
end