Skip to content

Instantly share code, notes, and snippets.

View radar's full-sized avatar

Ryan Bigg radar

View GitHub Profile
<%= f.label :foo %>
<%= f.text_area :foo %>
<%= f.fields_for :images do |image_field| %>
<% if image_field.object.new_record? %>
<%= render 'image_fields', :f => builder %>
<% end %>
<% end %>
response = RestClient.get 'http://localhost:3000/wallet_attributes', { :Authorization => "Token token=abc", :params => {:id => 50, 'foo' => 'bar'} }
class SuggestionController < ApplicationController
def vote
end
def get
end
end
<% provide(:title, "Create course") %>
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="custom-form chapter">
<%= form_for(@course) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.label :title %>
class BooksController < ApplicationController
before_filter :authenticate_user!
def index
@books = current_user.books
end
def new
@book = Book.new
end
class AddPriceToProduct < ActiveRecord::Migration
def self.up
add_column :products, :price, :decimal,
:precision => 8, :scale => 2, :default => 0
end
def self.down
remove_column :products, :price
end
end
## /users/edit.html.erb
<% form_for [:cp, @user], :url => { :action => 'update', :id => @user.id } do |f| %>
...
<%= collection_select :users, :show_id, Show.find(:all), :id, :name, { :prompt => true } %>
## users_controller.rb
@user.shows << Show.find(params[:users][:show_id])
## error
ActiveRecord::AssociationTypeMismatch in Cp/usersController#update
@radar
radar / notify.rb
Created September 19, 2014 00:11 — forked from EminenceHC/notify.rb
userJson = {
student: {}
}
if discharge_date
userJson["student"].merge(discharge_date: value)
end
class EventController < ApplicationController
def edit
event
end
private
def event
@event ||= Event.find(params[:id])
end