is an instance variable in an action of a controller available for all the controllers view?
- by fenec
I am just trying to printout the parameters that have been entered into my form.
basically i create a new bet then i display the parameters:
MIGRATION
enter code here
class CreateBets < ActiveRecord::Migration
def self.up
create_table :bets do |t|
t.integer :accepted ,:default = 0
t.integer :user_1_id #proposer
t.integer :user_2_id #receiver
t.integer :team_1_id #proposer's team
t.integer :team_2_id #receiver's team
t.integer :game_id
t.integer :winner
t.integer :amount
t.timestamps
end
end
def self.down
drop_table :bets
end
end
CONTROLLER
bets_controller.erb
enter code here
class BetsController < ApplicationController
def index
redirect_to new_bet_path
end
def new
@b=Bet.new
end
def create
@@points=params[:points]
@@winner=params[:winner]
end
end
VIEWS
New.erb
New Bet
<% facebook_form_for Bet.new do |f| %>
<%= f.text_field :amount, :label=>"points" %>
<%= f.text_field :winner, :label=>"WinningTeam" %>
<%= f.buttons "Bet" %>
<% end %>
create.erb
enter code here
points:<%= @@points %>
<br>
winner:<%= @@winner %>