Skip to content

Instantly share code, notes, and snippets.

format.json {render :json => @genres.to_json(:only => [:id, :name])}
@meltzerj
meltzerj / gist:894078
Created March 30, 2011 08:46
Full trace
app/controllers/profiles_controller.rb:16:in `update'
actionpack (3.0.4) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.4) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.4) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.4) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.4) lib/abstract_controller/callbacks.rb:18:in `process_action'
activesupport (3.0.4) lib/active_support/callbacks.rb:435:in `_run__270589929__process_action__944252406__callbacks'
activesupport (3.0.4) lib/active_support/callbacks.rb:409:in `send'
activesupport (3.0.4) lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
activesupport (3.0.4) lib/active_support/callbacks.rb:93:in `send'
@meltzerj
meltzerj / gist:895368
Created March 30, 2011 21:39
Full stack trace
activerecord (3.0.4) lib/active_record/base.rb:1558:in `attributes='
activerecord (3.0.4) lib/active_record/base.rb:1554:in `each'
activerecord (3.0.4) lib/active_record/base.rb:1554:in `attributes='
activerecord (3.0.4) lib/active_record/persistence.rb:127:in `update_attributes'
activerecord (3.0.4) lib/active_record/transactions.rb:292:in `with_transaction_returning_status'
activerecord (3.0.4) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
activerecord (3.0.4) lib/active_record/transactions.rb:207:in `transaction'
activerecord (3.0.4) lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
activerecord (3.0.4) lib/active_record/persistence.rb:126:in `update_attributes'
activerecord (3.0.4) lib/active_record/associations/association_proxy.rb:218:in `send'
Here's the update action:
def update
@user = current_user
@profile = @user.profile
respond_to do |format|
if @profile.update_attributes(params[:profile])
format.html { redirect_to(@profile, :notice => 'Profile was successfully updated.') }
else
format.html { render :action => "edit" }
@meltzerj
meltzerj / gist:895380
Created March 30, 2011 21:45
Edit view
<%= form_for(:profile, @profile, :url => {:controller => "profiles", :action => "update"}, :html => { :multipart => true, :method => :put }) do |f| %>
<% if @user.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<div class="field">
<%= f.label :genre_id, "Genres" %><br />
<%= f.text_field :genre_id, :id => 'genre_field' %>
</div>
Started POST "/videos/465" for 127.0.0.1 at Fri Apr 01 18:26:25 -0700 2011
Processing by VideosController#destroy as HTML
Parameters: {"authenticity_token"=>"F2uF4FDDSPw+jHHGtsosGLjHwkDUg/nre5u+WEPPDUY=", "id"=>"465"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 57 LIMIT 1
Video Load (0.3ms) SELECT "videos".* FROM "videos" WHERE "videos"."id" = 465 AND ("videos".user_id = 57) ORDER BY videos.rank_sum DESC LIMIT 1
Genre Load (0.3ms) SELECT * FROM "genres" INNER JOIN "genres_videos" ON "genres".id = "genres_videos".genre_id WHERE ("genres_videos".video_id = 465 )
Topicable Load (0.3ms) SELECT "topicables".* FROM "topicables" WHERE ("topicables".video_id = 465)
AREL (0.4ms) DELETE FROM "topicables" WHERE "topicables"."id" = 89
AREL (0.1ms) DELETE FROM "topicables" WHERE "topicables"."id" = 90
AREL (0.1ms) DELETE FROM "videos" WHERE "videos"."id" = 465
v class="topic_holder">
<% @video.topics.uniq.each do |topic| %>
<div class ="topic round">
<%= link_to "#{topic.name}", "#", :class => 'topic_link' %>
<% topicable = Topicable.find_by_video_id_and_topic_id(@video.id, topic.id) %>
<%= link_to "x", topicable_path(topicable.id), :method => :delete, :class => 'topic_delete' %>
</div>
<% end %>
</div>
<%= form_for @video, :url => {:action => "update"}, :remote => true do |f| %>
root :to => "videos#index"
resources :videos
resources :video_votes
resources :users
resources :profiles
resources :genres
resources :topics
resources :topicables
resource :session
select: function(event, ui) {
var url = $('.edit_video').attr('action');
var val = ui.item.topic.name;
$.ajax({type:"PUT", url:url, data:{video:{topic_names:val}}});
return false;
}