i trying ruby on rails work sql server 2005 on network windows 7 64-bit development machine.
i edited database.yml:
development: <<: *default adapter: sqlserver dsn: odbc_system_dsn username: admin password: ******** host: 111.222.333.444 i completed tutorial (well @ least part stuck now) , worked fine: http://guides.rubyonrails.org/getting_started.html
one problem tutorial creates batabase tables , must use existing tables.
i created following table testing purposes:
create table [dbo].[employee]( [emp_id] [int] null, [emp_name] [nchar](10) collate sql_latin1_general_cp1_ci_as null ) on [primary] i ran these commands:
rails generate scaffold employee rake db:migrate rails_env=development and appeared stuff got created. sending browser here: http://localhost:3000/employees/new
then received error: no route matches [post] "/employees/new"
not sure whats going on since ruby explanations seem in short supply, tried adding routes.rb:
post 'employees/show' i got farther if guess right. tried:
post 'employees/new' then got error (it seems doesn't recognize column name): nomethoderror in employees#new
from code:
<p> <%= f.label :id %><br> <%= f.text_field :emp_id %> </p> i trying see if can see database because setting challenge without clear instructions. seems may not not knowing how supposed work not helpful. seems every example find different without explanation.
i suggest not playing scaffolding or routing until can verify rails can talk db, , models mapped correctly db tables.
rails console friend. use console , create test models in app/models.
rails table , column names lower case, stick format, @ least until can working.
rails table names also, unless otherwise specified, plural of model name. in order make simple test case purposes need name table employees, , model name employee.
then run rails console, , type employee @ prompt. if works correctly should see console write model name , column names you.
after simple test can more confident continue next steps, since should know database connection working properly.
Comments
Post a Comment