Skip to content

Commit

Permalink
Drop :dashboard namespace for route helpers
Browse files Browse the repository at this point in the history
Apply this commit to remove the :dashboard namespace on routes made
using the route helper. This means that it is not required anymore to
link to a dashboard page using dashboard_video_path, it can be done
using video_path. It is not required to use [:dashboard, :videos],
:videos can just be used.

When linking to a public asset through the dashboard, remember to use
the subdomain key in the URL helper to make sure the link points to the
appropiate subdomain.
  • Loading branch information
danirod committed Aug 11, 2017
1 parent be2372e commit 49489a9
Show file tree
Hide file tree
Showing 42 changed files with 199 additions and 199 deletions.
6 changes: 3 additions & 3 deletions app/controllers/dashboard/opinions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ def new
def create
@opinion = Opinion.new(opinion_params)
if @opinion.save
redirect_to [:dashboard, :opinions], notice: t('.created')
redirect_to :opinions, notice: t('.created')
else
render :new
end
end

def update
if @opinion.update_attributes(opinion_params)
redirect_to [:dashboard, :opinions], notice: t('.updated')
redirect_to :opinions, notice: t('.updated')
else
render :edit
end
end

def destroy
@opinion.destroy!
redirect_to [:dashboard, :opinions], notice: t('.destroyed')
redirect_to :opinions, notice: t('.destroyed')
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/dashboard/playlists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ def new
def create
@playlist = Playlist.new(playlist_params)
if @playlist.save
redirect_to [:dashboard, @playlist], notice: t('.created')
redirect_to @playlist, notice: t('.created')
else
render :new
end
end

def update
if @playlist.update_attributes(playlist_params)
redirect_to [:dashboard, @playlist], notice: t('.updated')
redirect_to @playlist, notice: t('.updated')
else
render :edit
end
end

def destroy
@playlist.destroy!
redirect_to [:dashboard, :playlists], notice: t('.destroyed')
redirect_to :playlists, notice: t('.destroyed')
end

def videos
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/dashboard/topics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ def new
def create
@topic = Topic.new(topic_params)
if @topic.save
redirect_to [:dashboard, @topic], notice: t('.created')
redirect_to @topic, notice: t('.created')
else
render :new
end
end

def update
if @topic.update_attributes(topic_params)
redirect_to [:dashboard, @topic], notice: t('.updated')
redirect_to @topic, notice: t('.updated')
else
render :edit
end
end

def destroy
@topic.destroy!
redirect_to [:dashboard, :topics], notice: t('.destroyed')
redirect_to :topics, notice: t('.destroyed')
end

private
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/dashboard/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ def new
def create
@user = User.new(user_params)
if @user.save
redirect_to [:dashboard, @user], notice: t('.created')
redirect_to @user, notice: t('.created')
else
render :new
end
end

def update
if @user.update_attributes(user_params)
redirect_to [:dashboard, @user], notice: t('.updated')
redirect_to @user, notice: t('.updated')
else
render :edit
end
Expand All @@ -30,9 +30,9 @@ def update
def destroy
if @user != current_user
@user.destroy!
redirect_to [:dashboard, :users], notice: t('.destroyed')
redirect_to :users, notice: t('.destroyed')
else
redirect_to [:dashboard, :users], error: t('.current_user')
redirect_to :users, error: t('.current_user')
end
end

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/dashboard/videos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@ def new
def create
@video = Video.new(video_params)
if @video.save
redirect_to [:dashboard, @video.playlist, @video], notice: t('.created')
redirect_to [@video.playlist, @video], notice: t('.created')
else
render :new
end
end

def update
if @video.update_attributes(video_params)
redirect_to [:dashboard, @video.playlist, @video], notice: t('.updated')
redirect_to [@video.playlist, @video], notice: t('.updated')
else
render :edit
end
end

def destroy
@video.destroy!
redirect_to [:dashboard, :videos], notice: t('.destroyed')
redirect_to :videos, notice: t('.destroyed')
end

def move
respond_to do |format|
if params[:direction] == "up"
@video.move_higher
format.json { render json: { position: @video.position, direction: "up" } }
format.html { redirect_to [:videos, :dashboard, @video.playlist], notice: t('.moved') }
format.html { redirect_to [:videos, @video.playlist], notice: t('.moved') }
elsif params[:direction] == "down"
@video.move_lower
format.json { render json: { position: @video.position, direction: "down" } }
format.html { redirect_to [:videos, :dashboard, @video.playlist], notice: t('.moved') }
format.html { redirect_to [:videos, @video.playlist], notice: t('.moved') }
end
end
end
Expand Down
24 changes: 12 additions & 12 deletions app/helpers/dashboard/videos_helper.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module Dashboard::VideosHelper
def dashboard_video_path(video, options = {})
dashboard_playlist_video_path(video, options.merge(playlist_id: video.playlist))
def video_path(video, options = {})
playlist_video_path(video, options.merge(playlist_id: video.playlist))
end

def edit_dashboard_video_path(video, options = {})
edit_dashboard_playlist_video_path(video, options.merge(playlist_id: video.playlist))
def edit_video_path(video, options = {})
edit_playlist_video_path(video, options.merge(playlist_id: video.playlist))
end

def move_dashboard_video_path(video, options = {})
move_dashboard_playlist_video_path(video, options.merge(playlist_id: video.playlist))
def move_video_path(video, options = {})
move_playlist_video_path(video, options.merge(playlist_id: video.playlist))
end

def dashboard_video_url(video, options = {})
dashboard_playlist_video_url(video, options.merge(playlist_id: video.playlist))
def video_url(video, options = {})
playlist_video_url(video, options.merge(playlist_id: video.playlist))
end

def edit_dashboard_video_url(video, options = {})
edit_dashboard_playlist_video_url(video, options.merge(playlist_id: video.playlist))
def edit_video_url(video, options = {})
edit_playlist_video_url(video, options.merge(playlist_id: video.playlist))
end

def move_dashboard_video_url(video, options = {})
move_dashboard_playlist_video_url(video, options.merge(playlist_id: video.playlist))
def move_video_url(video, options = {})
move_playlist_video_url(video, options.merge(playlist_id: video.playlist))
end
end
10 changes: 5 additions & 5 deletions app/views/dashboard/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@
<div class="col-xs-6 col-sm-3">
<h1><span class="glyphicon glyphicon-facetime-video"></span> <%= @videos %></h1>
<p class="lead"><%= t('.videos', count: @videos) %></p>
<p><%= link_to t('.manage_videos'), [:dashboard, :videos], class: 'btn btn-default btn-block' %></p>
<p><%= link_to t('.manage_videos'), :videos, class: 'btn btn-default btn-block' %></p>
</div>

<div class="col-xs-6 col-sm-3">
<h1><span class="glyphicon glyphicon-list"></span> <%= @playlists %></h1>
<p class="lead"><%= t('.playlists', count: @playlists) %></p>
<p><%= link_to t('.manage_playlists'), [:dashboard, :playlists], class: 'btn btn-default btn-block' %></p>
<p><%= link_to t('.manage_playlists'), :playlists, class: 'btn btn-default btn-block' %></p>
</div>

<div class="col-xs-6 col-sm-3">
<h1><span class="glyphicon glyphicon-book"></span> <%= @topics %></h1>
<p class="lead"><%= t('.topics', count: @topics) %></p>
<p><%= link_to t('.manage_topics'), [:dashboard, :topics], class: 'btn btn-default btn-block' %></p>
<p><%= link_to t('.manage_topics'), :topics, class: 'btn btn-default btn-block' %></p>
</div>

<div class="col-xs-6 col-sm-3">
<h1><span class="glyphicon glyphicon-user"></span> <%= @users %></h1>
<p class="lead"><%= t('.users', count: @users) %></p>
<p><%= link_to t('.manage_users'), [:dashboard, :users], class: 'btn btn-default btn-block' %></p>
<p><%= link_to t('.manage_users'), :users, class: 'btn btn-default btn-block' %></p>
</div>

<div class="col-xs-6 col-sm-3">
<h1><span class="glyphicon glyphicon-user"></span> <%= @opinions %></h1>
<p class="lead"><%= t('.opinions', count: @opinions) %></p>
<p><%= link_to t('.manage_opinions'), [:dashboard, :opinions], class: 'btn btn-default btn-block' %></p>
<p><%= link_to t('.manage_opinions'), :opinions, class: 'btn btn-default btn-block' %></p>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/dashboard/opinions/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= simple_form_for [:dashboard, @opinion] do |form| %>
<%= simple_form_for @opinion do |form| %>
<%= form.input :from %>
<%= form.input :message, as: :text %>
<%= form.input :url, as: :url %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/dashboard/opinions/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<% content_for :header do %>
<ol class="breadcrumb">
<li><%= link_to t('.dashboard'), :dashboard %></li>
<li><%= link_to t('.opinions'), [:dashboard, :opinions] %></li>
<li><%= link_to @opinion, [:dashboard, @opinion] %></li>
<li><%= link_to t('.dashboard'), :root %></li>
<li><%= link_to t('.opinions'), :opinions %></li>
<li><%= link_to @opinion, @opinion %></li>
<li class="current"><%= t('.edit') %></li>
</ol>
<h1><%= @playlist %></h1>
<% end %>

<% content_for :toolbar do %>
<%= link_to t('.cancel'), [:dashboard, @opinion], class: 'btn btn-default' %>
<%= link_to t('.cancel'), @opinion, class: 'btn btn-default' %>
<% end %>

<%= render 'form' %>
10 changes: 5 additions & 5 deletions app/views/dashboard/opinions/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<% content_for :header do %>
<ol class="breadcrumb">
<li><%= link_to t('.dashboard'), :dashboard %></li>
<li><%= link_to t('.dashboard'), :root %></li>
<li class="current"><%= t('.opinions') %></li>
</ol>
<h1><%= t('.opinions') %></h1>
<% end %>

<% content_for :toolbar do %>
<%= link_to t('.new_opinion'), [:new, :dashboard, :opinion], class: 'btn btn-success' %>
<%= link_to t('.new_opinion'), [:new, :opinion], class: 'btn btn-success' %>
<% end %>

<table class="table table-default">
Expand All @@ -20,10 +20,10 @@
<tbody>
<% @opinions.each do |opinion| %>
<tr>
<td><%= link_to opinion.from, [:dashboard, opinion] %></td>
<td><%= link_to opinion.from, opinion %></td>
<td>
<%= link_to t('.edit'), [:edit, :dashboard, opinion], class: 'btn btn-xs btn-default' %>
<%= button_to t('.destroy'), [:dashboard, opinion], method: :delete, class: 'btn btn-xs btn-danger', data: { confirm: t('.really_destroy') } %>
<%= link_to t('.edit'), [:edit, opinion], class: 'btn btn-xs btn-default' %>
<%= button_to t('.destroy'), opinion, method: :delete, class: 'btn btn-xs btn-danger', data: { confirm: t('.really_destroy') } %>
</td>
</tr>
<% end %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/dashboard/opinions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<% content_for :header do %>
<ol class="breadcrumb">
<li><%= link_to t('.dashboard'), :dashboard %></li>
<li><%= link_to t('.opinions'), [:dashboard, :opinions] %></li>
<li><%= link_to t('.dashboard'), :root %></li>
<li><%= link_to t('.opinions'), :opinions %></li>
<li class="current"><%= t('.new_opinion') %></li>
</ol>
<h1><%= t('.new_opinion') %></h1>
<% end %>

<% content_for :toolbar do %>
<%= link_to t('.cancel'), [:dashboard, :opinions], class: 'btn btn-default' %>
<%= link_to t('.cancel'), :opinions, class: 'btn btn-default' %>
<% end %>

<%= render 'form' %>
8 changes: 4 additions & 4 deletions app/views/dashboard/opinions/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<% content_for :header do %>
<ol class="breadcrumb">
<li><%= link_to t('.dashboard'), :dashboard %></li>
<li><%= link_to t('.opinions'), [:dashboard, :opinions] %></li>
<li><%= link_to t('.dashboard'), :root %></li>
<li><%= link_to t('.opinions'), :opinions %></li>
<li class="current"><%= @opinion %></li>
</ol>
<h1><%= @opinion %></h1>
<% end %>

<% content_for :toolbar do %>
<%= link_to t('.edit'), [:edit, :dashboard, @opinion], class: 'btn btn-default' %>
<%= button_to t('.destroy'), [:dashboard, @opinion], method: :delete, class: 'btn btn-danger', data: { confirm: t('.really_destroy') } %>
<%= link_to t('.edit'), [:edit, @opinion], class: 'btn btn-default' %>
<%= button_to t('.destroy'), @opinion, method: :delete, class: 'btn btn-danger', data: { confirm: t('.really_destroy') } %>
<% end %>

<table class="table table-default">
Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboard/playlists/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= simple_form_for [:dashboard, @playlist] do |form| %>
<%= simple_form_for @playlist do |form| %>
<%= form.input :title %>
<%= form.input :description, as: :text %>
<%= form.input :youtube_id %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/dashboard/playlists/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<% content_for :header do %>
<ol class="breadcrumb">
<li><%= link_to t('.dashboard'), :dashboard %></li>
<li><%= link_to t('.playlists'), [:dashboard, :playlists] %></li>
<li><%= link_to @playlist, [:dashboard, @playlist] %></li>
<li><%= link_to t('.dashboard'), :root %></li>
<li><%= link_to t('.playlists'), :playlists %></li>
<li><%= link_to @playlist, @playlist %></li>
<li class="current"><%= t('.edit') %></li>
</ol>
<h1><%= @playlist %></h1>
<% end %>

<% content_for :toolbar do %>
<%= link_to t('.cancel'), [:dashboard, @playlist], class: 'btn btn-default' %>
<%= link_to t('.cancel'), @playlist, class: 'btn btn-default' %>
<% end %>

<%= render 'form' %>
14 changes: 7 additions & 7 deletions app/views/dashboard/playlists/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<% content_for :header do %>
<ol class="breadcrumb">
<li><%= link_to t('.dashboard'), :dashboard %></li>
<li><%= link_to t('.dashboard'), :root %></li>
<li class="current"><%= t('.playlists') %></li>
</ol>
<h1><%= t('.playlists') %></h1>
<% end %>

<% content_for :toolbar do %>
<%= link_to t('.new_playlist'), [:new, :dashboard, :playlist], class: 'btn btn-success' %>
<%= link_to t('.new_playlist'), [:new, :playlist], class: 'btn btn-success' %>
<% end %>

<table class="table table-default">
Expand All @@ -22,12 +22,12 @@
<tbody>
<% @playlists.each do |playlist| %>
<tr>
<td><%= link_to playlist.title, [:dashboard, playlist] %></td>
<td><%= link_to playlist.topic.title, [:dashboard, playlist.topic] rescue t('.no_topic') %></td>
<td><%= link_to playlist.videos.length, [:videos, :dashboard, playlist] %></td>
<td><%= link_to playlist.title, playlist %></td>
<td><%= link_to playlist.topic.title, playlist.topic rescue t('.no_topic') %></td>
<td><%= link_to playlist.videos.length, [:videos, playlist] %></td>
<td>
<%= link_to t('.edit'), [:edit, :dashboard, playlist], class: 'btn btn-xs btn-default' %>
<%= button_to t('.destroy'), [:dashboard, playlist], method: :delete, class: 'btn btn-xs btn-danger', data: { confirm: t('.really_destroy') } %>
<%= link_to t('.edit'), [:edit, playlist], class: 'btn btn-xs btn-default' %>
<%= button_to t('.destroy'), playlist, method: :delete, class: 'btn btn-xs btn-danger', data: { confirm: t('.really_destroy') } %>
</td>
</tr>
<% end %>
Expand Down
Loading

0 comments on commit 49489a9

Please sign in to comment.