Skip to content

Instantly share code, notes, and snippets.

View rishighan's full-sized avatar
:octocat:
Focusing

Rishi Ghan rishighan

:octocat:
Focusing
View GitHub Profile
@rishighan
rishighan / _form.html.erb
Created November 17, 2011 15:09
the form view
<%= javascript_tag do %>
<%= render "plupload.js"%>
<% end%>
<%= form_for(@post) do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
@rishighan
rishighan / _form.html.erb
Created November 22, 2011 21:18
plupload
<%= javascript_tag do %>
<%= render "jsupload.js"%>
<% end%>
<%= form_for(@post) do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
@rishighan
rishighan / params_paperclip
Created November 24, 2011 00:28
params hash for the plupload widget.
Parameters: {"uploader_0_status"=>"done", "uploader_0_name"=>"IMG_1181.JPG", "commit"=>"Creat
e Post", "post"=>{"category"=>"asd", "title"=>"asd", "content"=>"asd", "attachments_attributes"
=>{"0"=>{"photo"=>#<ActionDispatch::Http::UploadedFile:0x1367296d8 @headers="Content-Dispositio
n: form-data; name=\"post[attachments_attributes][0][photo]\"; filename=\"IMG_1169.JPG\"\r\nCon
tent-Type: image/jpeg\r\n", @content_type="image/jpeg", @tempfile=#<File:/var/folders/gs/btvwgg
x90nn096h8zqy5mhnm0000gn/T/RackMultipart20111123-2763-1ay9rz2-0>, @original_filename="IMG_1169.
JPG">, "attachment_category_id"=>"2"}}}, "uploader_0_tmpname"=>"p16f9gerlk15ep1kf12lc1bp81gsq4.
JPG", "authenticity_token"=>"VlL0nWBuKGsQh+k/vHxTffGlEtloXlOEYLQTHkCtBes=", "utf8"=>"\342\234\2
23", "uploader_count"=>"1"}
class AttachmentCategory < ActiveRecord::Base
belongs_to :post
has_many :attachments
accepts_nested_attributes_for :attachments
validates :category_name, :presence =>true
end
@rishighan
rishighan / _form.html.erb
Created November 25, 2011 21:06
form code
<%= form_for(@post) do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
@rishighan
rishighan / _form.html.erb
Created November 30, 2011 00:18
_form.html.erb
<%= nested_form_for(@post, :remote=>true) do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
class Category < ActiveRecord::Base
has_many :posts
validates :category_name, :category_description, :presence => true
end
<h1>Listing posts</h1>
<%= link_to 'New Post', new_admin_post_path %>
<p>
<% @posts.each do |post| %>
<h2><%= post.title %></h2>
filed under: <%= post.category_id %>
<br><br>
<%= post.content %><br><br>
@rishighan
rishighan / _form.html.erb
Created January 23, 2012 00:54
Attachment model
<%= nested_form_for([:admin, @post], :remote=>true, :html => { :multipart => true }) do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
@rishighan
rishighan / _form.html.erb
Created January 25, 2012 17:55
form view.
<%= nested_form_for([:admin, @post], :remote=>true, :html => { :multipart => true }) do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>