Skip to content

Instantly share code, notes, and snippets.

@JamesZoft
Last active December 16, 2015 08:49
Show Gist options
  • Save JamesZoft/5408840 to your computer and use it in GitHub Desktop.
Save JamesZoft/5408840 to your computer and use it in GitHub Desktop.
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 %>
FypDbeditForm::Application.routes.draw do
resources :match_entries, :controller => :match_entry
resources :tournament_entries, :controller => :tournament_entry
end
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
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
@jaymiejones86
Copy link

I would do

<% TournamentEntry.each do |entry| %>
  <%= entry.name %> <%= entry.links %> <br />
<%end %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment