I''m missing something here. The settings table just has a couple
fields, id, name, value, and group. name, value and group are all
strings, and id and name are the only ones with not null constraints.
When I run this, it says @appname is nil. What am I missing?
settings_test.rb:
require File.dirname(__FILE__) + ''/../test_helper''
class SettingTest < Test::Unit::TestCase
fixtures :settings
# Replace this with your real tests.
def test_truth
assert_kind_of Setting, @appname
end
end
settings.yml:
appname:
id: 1001
name: appname
value: TestApp
appurl:
id: 1002
name: appurl
value: http://localhost:3000
logintitle:
id: 2001
name: logintitle
value: Login
group: user
loginwelcome:
id: 2002
name: loginwelcome
value: Welcome to the login area
group: user
> settings_test.rb: > > require File.dirname(__FILE__) + ''/../test_helper'' > > class SettingTest < Test::Unit::TestCase > fixtures :settingsdef setup @appname = Setting.find_by_name(''appname'') # or # @appname = Setting.find_by_value(''TestApp'') # or #@appname = Setting.find(1001) end # Replace this with your real tests.> def test_truth > assert_kind_of Setting, @appname > end > end > > > > settings.yml: > > appname: > id: 1001 > name: appname > value: TestApp > > appurl: > id: 1002 > name: appurl > value: http://localhost:3000 > > logintitle: > id: 2001 > name: logintitle > value: Login > group: user > > loginwelcome: > id: 2002 > name: loginwelcome > value: Welcome to the login area > group: user >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 11/19/05, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m missing something here. The settings table just has a couple > fields, id, name, value, and group. name, value and group are all > strings, and id and name are the only ones with not null constraints. > When I run this, it says @appname is nil. What am I missing?...> appname: > id: 1001 > name: appname > value: TestAppIt is looking for the variable ''appname'' and the constant ''TestApp''. This should be appname: id: 1001 name: "appname" value: "TestApp" Hope that helps -- Cheers, Peter Donald RealityForge.org: http://www.realityforge.org
See http://manuals.rubyonrails.org/read/chapter/118#page319 On 11/18/05, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m missing something here. The settings table just has a couple > fields, id, name, value, and group. name, value and group are all > strings, and id and name are the only ones with not null constraints. > When I run this, it says @appname is nil. What am I missing? > > settings_test.rb: > > require File.dirname(__FILE__) + ''/../test_helper'' > > class SettingTest < Test::Unit::TestCase > fixtures :settings > > # Replace this with your real tests. > def test_truth > assert_kind_of Setting, @appname > end > end > > > > settings.yml: > > appname: > id: 1001 > name: appname > value: TestApp > > appurl: > id: 1002 > name: appurl > value: http://localhost:3000 > > logintitle: > id: 2001 > name: logintitle > value: Login > group: user > > loginwelcome: > id: 2002 > name: loginwelcome > value: Welcome to the login area > group: user > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Thanks, this is exactly what I was looking for. Pat On 11/18/05, Cuong Tran <cuong.tran-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> See > http://manuals.rubyonrails.org/read/chapter/118#page319 > > On 11/18/05, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''m missing something here. The settings table just has a couple > > fields, id, name, value, and group. name, value and group are all > > strings, and id and name are the only ones with not null constraints. > > When I run this, it says @appname is nil. What am I missing? > > > > settings_test.rb: > > > > require File.dirname(__FILE__) + ''/../test_helper'' > > > > class SettingTest < Test::Unit::TestCase > > fixtures :settings > > > > # Replace this with your real tests. > > def test_truth > > assert_kind_of Setting, @appname > > end > > end > > > > > > > > settings.yml: > > > > appname: > > id: 1001 > > name: appname > > value: TestApp > > > > appurl: > > id: 1002 > > name: appurl > > value: http://localhost:3000 > > > > logintitle: > > id: 2001 > > name: logintitle > > value: Login > > group: user > > > > loginwelcome: > > id: 2002 > > name: loginwelcome > > value: Welcome to the login area > > group: user > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >