-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lincoln Stewart
committed
Mar 30, 2014
1 parent
874e210
commit fef30f0
Showing
10 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# shows and adds sources | ||
class SourceController < ApplicationController | ||
def show | ||
@curriculum = Curricula.find_by_id(params[:id]) | ||
@sources = Source.grab_sources_for_curriculum @curriculum | ||
end | ||
|
||
def edit | ||
@curriculum = Curricula.find_by_id(params[:id]) | ||
@source = Source.new(source_params) | ||
@source.creator = current_user | ||
@source.curricula = @curriculum | ||
if @source.save | ||
flash[:success] = 'Success' | ||
else | ||
flash[:danger] = 'Error! Try submitting again' | ||
end | ||
@sources = Source.grab_sources_for_curriculum @curriculum | ||
respond_to do |format| | ||
format.js | ||
end | ||
end | ||
|
||
private | ||
|
||
def source_params | ||
params.require(:source).permit(:link, :source_tag) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<% unless @sources.blank? %> | ||
<% @sources.each do |s| %> | ||
<div class="list-group-item"> | ||
<a class="list-group-item-heading" href=<%= s.link %>> | ||
<%= s.source_tag %> | ||
</a> | ||
</div> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$('#status').html("<%= escape_javascript(render :partial => 'shared/flash_messages') %>"); | ||
$('#source-list').html("<%= escape_javascript(render :partial => 'sources') %>"); | ||
$('#source_link').val(""); | ||
$('#source_source_tag').val(""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-3"> | ||
<div id="status"> | ||
</div> | ||
<%= form_for :source, :url => source_edit_path(:id => @curriculum.id), :role => "form", :class => "form", :method => :post, :remote => true do |f| %> | ||
<div class="form-group"> | ||
<%= f.text_field :link, type: "text", placeholder: "url for source", class: "form-control", :autofocus => true %> | ||
</div> | ||
<div class="form-group"> | ||
<%= f.text_field :source_tag, type: "text", placeholder: "tag for source", class: "form-control", :autofocus => true %> | ||
</div> | ||
<div class="form-group"> | ||
<%= f.submit "add source", class: "btn btn-primary pull-right" %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<div class="col-md-9"> | ||
<div class="panel panel-info"> | ||
<div class="panel-heading"> | ||
Sources | ||
</div> | ||
<div class="list-group" id="source-list"> | ||
<% unless @sources.blank? %> | ||
<% @sources.each do |s| %> | ||
<div class="list-group-item"> | ||
<a class="list-group-item-heading" href=<%= s.link %>> | ||
<%= s.source_tag %> | ||
</a> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddLinkToSource < ActiveRecord::Migration | ||
def change | ||
add_column :sources, :link, :text | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters