Last active
December 16, 2015 08:49
-
-
Save JamesZoft/5408840 to your computer and use it in GitHub Desktop.
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
Enter new tournament information | |
<hr> | |
<%= form_for @tournamentEntry do |f| -%> | |
Entry requirements: <%= f.text_field :entry_reqs %><br /> | |
Links: <%= f.text_field :links %> <br /> | |
Format: <%= f.text_field :format %> <br /> | |
Future: <%= f.radio_button(:status, :future) %> <br /> | |
Past: <%= f.radio_button(:status, :past) %> <br /> | |
Ongoing: <%= f.radio_button(:status, :ongoing) %> <br /> | |
Location: <%= f.text_field :location %> <br /> | |
Name: <%= f.text_field :name %> <br /> | |
Prizes: <%= f.text_field :prizes %> <br /> | |
Sponsor: <%= f.text_field :sponsor %> <br /> | |
<%= f.submit %> | |
<% end -%> | |
<hr> | |
Display all tournaments | |
<% TournamentEntry.find_each do |entry| %> | |
<%= entry.name %> <%= entry.inspect %> <br /> | |
<%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
FypDbeditForm::Application.routes.draw do | |
resources :match_entries, :controller => :match_entry | |
resources :tournament_entries, :controller => :tournament_entry | |
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
class TournamentEntry < ActiveRecord::Base | |
attr_accessible :entry_reqs, :format, :future, :links, :location, :name, :ongoing, :past, :prizes, :sponsor#, :status | |
# attr_accessor :status | |
def status | |
@status | |
end | |
def status=(val) | |
@past = nil | |
@future = nil | |
@ongoing = nil | |
if(val == "ongoing") | |
@ongoing = true | |
elsif(val == "past") | |
@past = true | |
elsif(val == "future") | |
@future = true | |
end | |
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
class TournamentEntryController < ApplicationController | |
def new | |
@tournamentEntry = TournamentEntry.new | |
end | |
def create | |
@tournamentEntry = TournamentEntry.new(params[:tournamentEntry]) | |
if @tournamentEntry.save | |
redirect_to new_tournament_entry_path | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would do