Permalink
Browse files

modified various controllers and views to create resourceful routes f…

…or bumps
  • Loading branch information...
1 parent a0b628b commit bdb44510f45e8d93731d5411c1e980aca95b51cd Tom O'Donnell committed May 2, 2013
@@ -1,4 +1,4 @@
-class BumpController < ApplicationController
+class BumpsController < ApplicationController
require 'open-uri'
before_filter :authenticate_user!
@@ -7,6 +7,10 @@ def index
@user = current_user
@bumps = @user.bumps.includes(:band).where(:unbumped_at => nil).order("cred_value DESC")
end
+
+ def show
+
+ end
def new
# get the unique musicbrainz to grab data from musicbrainz and lastfm
@@ -57,6 +61,10 @@ def new
redirect_to :action => 'index'
end
+
+ def edit
+
+ end
def destroy
# find bump via url and define unbumped_at
@@ -1,2 +0,0 @@
-module BumpHelper
-end
@@ -0,0 +1,2 @@
+module BumpsHelper
+end
@@ -18,7 +18,7 @@
<%= time_ago_in_words(band.created_at) %> ago</p>
<% if user_signed_in? %>
- <%= render :partial => "bump/manage_bump", :locals => {:user => current_user, :band => band, :bump => band.bumps.where(:user_id => current_user.id, :unbumped_at => nil).first} %>
+ <%= render :partial => "bumps/manage_bump", :locals => {:user => current_user, :band => band, :bump => band.bumps.where(:user_id => current_user.id, :unbumped_at => nil).first} %>
<% end %>
<% end %>
</div>
@@ -41,7 +41,7 @@
<%= band.bumps.length %> bumps since <%= time_ago_in_words(band.created_at) %> ago</p>
<% if user_signed_in? %>
- <%= render :partial => "bump/manage_bump", :locals => {:user => current_user, :band => band, :bump => band.bumps.where(:user_id => current_user.id, :unbumped_at => nil).first} %>
+ <%= render :partial => "bumps/manage_bump", :locals => {:user => current_user, :band => band, :bump => band.bumps.where(:user_id => current_user.id, :unbumped_at => nil).first} %>
<% end %>
<% end %>
</div>
@@ -1,7 +1,7 @@
<% unless bump.nil? %>
- <p><%= number_to_currency(bump.cred_value, :unit => '') %> Cred <%= link_to 'Unbump', bump_destroy_url(:id => bump.id), :confirm => "Are you sure?", :class => "btn btn-small btn-danger pull-right" %></p>
+ <p><%= number_to_currency(bump.cred_value, :unit => '') %> Cred <%= link_to 'Unbump', bump_path(bump), :confirm => "Are you sure?", :method => :delete, :class => "btn btn-small btn-danger pull-right" %></p>
<% else %>
- <%= form_tag("/bump/new", :method => 'post') do %>
+ <%= form_tag(new_bump_path, :method => 'get') do %>
<%= text_field_tag(:invested_cred, nil, :placeholder => "Cred") %>
<%= hidden_field_tag(:mbid, band.mbid) %>
<%= submit_tag "Bump", :class => "btn btn-success pull-right" %>
File renamed without changes.
@@ -11,7 +11,7 @@
<h3><%= link_to bump.band.name, band_path(bump.band) %></h3>
<p>
<%= number_to_currency(bump.cred_value, :unit => '') %> Cred
- <%= link_to 'Unbump', bump_destroy_url(:id => bump.id), :confirm => "Are you sure?", :class => "btn btn-small btn-danger" %>
+ <%= link_to 'Unbump', bump_path(bump), :confirm => "Are you sure?", :action => :delete, :class => "btn btn-small btn-danger" %>
</p>
</div>
</li>
File renamed without changes.
@@ -18,7 +18,7 @@
# devise namespace %>
<li><%= link_to 'Browse', bands_path %></li>
<li><%= link_to 'Search', :controller => '/search', :action => 'index' %></li>
- <li><%= link_to 'Bands You Bump', :controller => '/bump', :action => 'index' %></li>
+ <li><%= link_to 'Bands You Bump', bumps_path %></li>
</ul>
<ul class="nav pull-right">
<%= render 'devise/menu/registration_items' %>
@@ -22,13 +22,13 @@
<p><%= "- " + artist.css("disambiguation").first.content unless artist.css("disambiguation").first.nil? %></p>
<% if @bands[i].nil? %>
- <%= form_tag("/bump/new", :method => 'post') do %>
+ <%= form_tag(new_bump_path, :method => 'get') do %>
<%= text_field_tag(:invested_cred, nil, :placeholder => "Cred") %>
<%= hidden_field_tag(:mbid, artist["id"]) %>
<%= submit_tag "Bump", :class => "btn btn-success pull-right" %>
<% end %>
<% else %>
- <%= render :partial => "bump/manage_bump", :locals => {:user => current_user, :band => @bands[i], :bump => @bands[i].bumps.where(:user_id => current_user.id, :unbumped_at => nil).first} %>
+ <%= render :partial => "bumps/manage_bump", :locals => {:user => current_user, :band => @bands[i], :bump => @bands[i].bumps.where(:user_id => current_user.id, :unbumped_at => nil).first} %>
<% end %>
</div>
@@ -17,7 +17,7 @@
<div class="thumbnail">
<%= image_tag band.image.url(:thumb) %>
<h3><%= link_to band.name, band_path(band) %></h3>
- <%= render :partial => "bump/manage_bump", :locals => {:user => @user, :band => band, :bump => @user.bumps.where(:band_id => band.id, :unbumped_at => nil).first} %>
+ <%= render :partial => "bumps/manage_bump", :locals => {:user => @user, :band => band, :bump => @user.bumps.where(:band_id => band.id, :unbumped_at => nil).first} %>
</div>
</li>
<% end %>
View
@@ -3,13 +3,16 @@
resources :friends, :only => [:index]
resources :bands, :only => [:index, :show]
+
+ resources :bumps
# match "bands" => "band#index"
# match "bands/:id" => "band#show", :as => :band
- get "bump/index"
- match "bump/new" => "bump#new", :as => :bump_new
- match "bump/destroy/:id" => "bump#destroy", :as => :bump_destroy
+# get "bump/index"
+# match "bump/new" => "bump#new", :as => :bump_new
+# match "bump/destroy/:id" => "bump#destroy", :as => :bump_destroy
+
get "search/index"
get "search/results"

0 comments on commit bdb4451

Please sign in to comment.