Where have the forms gone?

Hi,

I recently installed:

  • Aptana Studio 1.1.0.007007
  • Rails 2.0.2
  • Ruby 1.8.6

First thing I noticed was that now I needed SqlLite3. I changed the
database.yml to keep it like before:

development:
adapter: mysql
database: company_development
username: root
password:
host: localhost

I created a project. To my surprise now the .rhtml are now html.erb
And when creating a basic scaffold I can create new (lets say employees)
but the web interface is not showing the forms to enter the values for
the created entries.

What has gone mad? Maybe the sql thing?

Thanks in advance.

Hi,

Apparently my question is too dummy. But I’m still confused…
I’ve been working on a project all the time where by default MySql was
used and when creating a scaffold it would create .rhtml files

Now I noticed that I expects Sqlite3 and makes html.erb files.
Have I missed a big thing??

I want to keep using MySql, is changing the yml file enough?

Any info is appreciated.

On 17 Feb 2008, at 17:49, comopasta Gr wrote:

Hi,

Apparently my question is too dummy. But I’m still confused…
I’ve been working on a project all the time where by default MySql was
used and when creating a scaffold it would create .rhtml files

Scaffolding in rails has changed, and is no longer dynamic (off the
top of my head i think there’s a plugin to have old style scaffolding
if you really want it)

Now I noticed that I expects Sqlite3 and makes html.erb files.
Have I missed a big thing??

I want to keep using MySql, is changing the yml file enough?

yes.

On 18 Feb 2008, at 14:32, comopasta Gr wrote:

Thanks Frederick.

Well I guess I’ll have to learn to live with it.
I still don’t understand what is the point. At least now when trying
to
create a basic rails app I have to do more work…

  • Change back to MySql

rails -d mysql will create it with mysql setup

  • Scaffold is not creating the controller so I need to create the
    controller manually
  • The created controller is empty and now I have to fill it myself.

that shouldn’t be happening - it’s just the forms that don’t get
autoupdated. Are you doing something like

script/generate scaffold purchase order_id:integer amount:decimal

or are you just doing script/generate controller (that does just
generate an empty controller)

Fred

Thanks Frederick.

Well I guess I’ll have to learn to live with it.
I still don’t understand what is the point. At least now when trying to
create a basic rails app I have to do more work…

  • Change back to MySql
  • Scaffold is not creating the controller so I need to create the
    controller manually
  • The created controller is empty and now I have to fill it myself.

I guess I’m doing something wrong or in the wrong order, otherwise I
don’t understand that change.

Thanks.

conclussion (?). I should do like in the first process. But then I
should add the db columns in the scaffold generation as you mentioned.

This created all the basic stuff.
Any info when the dicussed changes where introduced? I wonder what else
I’ve been missing. I guess I find out soon when I start porting my old
application.

Cheers.

rails -d mysql will create it with mysql setup

Cool, I’ll start using that.


I started a project from scratch and go the next results:

1- Rails company

2- ruby script/generate scaffold Employee
Yes I got pretty much everything. I think the order in which I did the
process before affected the results. But now it seems ok. Contoller is
created and contains the basic methods as expected

3- I edit the database.yml to change to MySql

4- I edit the db/migrate/001_create_employees.rb to fill in some data to
the DB
The MySql DB is filled accordingly. Just added three string columns.

5- Go to http://127.0.0.1:3000/employees/new
No forms for the page to fill the columns in the db. The generated page
is:

Employees: new

New employee

Back


You are right. I’m not using generate scaffold purchase order_id:integer
amount:decimal. But if I recall correctly I’ve never done it in that way
before and I always got the basic stuff created automatically.


Now. I repeated the process with a different order:

1- rails -d mysql empresa

2- ruby script/generate model Empleado
This I didn’t do in the previous test.

3- rake db:migrate
Fill the DB after adding some lines to the migrate file

4- ruby script/generate scaffold Empleado
Well, this time running that didn’t generate the controller…so I
decided to create it myself.

5- ruby script/generate controller Empleados
And now it is created. But it is empty:

class EmpleadosController < ApplicationController
end

And the contents of the new.html.erb still didn’t have all the expected
forms:

New empleado

<%= error_messages_for :empleado %> <% form_for(@empleado) do |f| %>

<%= f.submit "Create" %>

<% end %> <%= link_to 'Back', empleados_path %>

conclussion (?). I should do like in the first process. But then I
should add the db columns in the scaffold generation as you mentioned. I
liked it better before, that’s still more work now isn’t it?

I am not an expert but I thought I had a basic understanding before.
Apparently I don’t :stuck_out_tongue:

Again, thanks for your time Fred.



The next will make this post huge. But maybe I helps pasting the output
of the commands for both procedures.

PROCEDURE ONE

C:\InstantRails\rails_apps>rails company
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create script/process
create test/fixtures
create test/functional
create test/integration
create test/mocks/development
create test/mocks/test
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application.rb
create app/helpers/application_helper.rb
create test/test_helper.rb
create config/database.yml
create config/routes.rb
create public/.htaccess
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/boot.rb
create config/environment.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/console
create script/destroy
create script/generate
create script/performance/benchmarker
create script/performance/profiler
create script/performance/request
create script/process/reaper
create script/process/spawner
create script/process/inspector
create script/runner
create script/server
create script/plugin
create public/dispatch.rb
create public/dispatch.cgi
create public/dispatch.fcgi
create public/404.html
create public/422.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.log

C:\InstantRails\rails_apps>cd company

C:\InstantRails\rails_apps\company>ruby script/generate scaffold
Employee
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/employees
exists app/views/layouts/
exists test/functional/
exists test/unit/
create app/views/employees/index.html.erb
create app/views/employees/show.html.erb
create app/views/employees/new.html.erb
create app/views/employees/edit.html.erb
create app/views/layouts/employees.html.erb
create public/stylesheets/scaffold.css
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/employee.rb
create test/unit/employee_test.rb
create test/fixtures/employees.yml
create db/migrate
create db/migrate/001_create_employees.rb
create app/controllers/employees_controller.rb
create test/functional/employees_controller_test.rb
create app/helpers/employees_helper.rb
route map.resources :employees

C:\InstantRails\rails_apps\company>rake db:migrate
(in C:/InstantRails/rails_apps/company)
== 1 CreateEmployees: migrating

– create_table(:employees)
→ 0.1300s
== 1 CreateEmployees: migrated (0.1300s)

PROCEDURE TWO

C:\InstantRails\rails_apps>rails -d mysql empresa
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create script/process
create test/fixtures
create test/functional
create test/integration
create test/mocks/development
create test/mocks/test
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application.rb
create app/helpers/application_helper.rb
create test/test_helper.rb
create config/database.yml
create config/routes.rb
create public/.htaccess
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/boot.rb
create config/environment.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/console
create script/destroy
create script/generate
create script/performance/benchmarker
create script/performance/profiler
create script/performance/request
create script/process/reaper
create script/process/spawner
create script/process/inspector
create script/runner
create script/server
create script/plugin
create public/dispatch.rb
create public/dispatch.cgi
create public/dispatch.fcgi
create public/404.html
create public/422.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.log

C:\InstantRails\rails_apps>cd empresa

C:\InstantRails\rails_apps\empresa>ruby script/generate model Empleado
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/empleado.rb
create test/unit/empleado_test.rb
create test/fixtures/empleados.yml
create db/migrate
create db/migrate/001_create_empleados.rb

C:\InstantRails\rails_apps\empresa>rake db:migrate
(in C:/InstantRails/rails_apps/empresa)
== 1 CreateEmpleados: migrating

– create_table(:empleados)
→ 0.1610s
== 1 CreateEmpleados: migrated (0.1610s)

C:\InstantRails\rails_apps\empresa>ruby script/generate scaffold
Empleado
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/empleados
exists app/views/layouts/
exists test/functional/
exists test/unit/
create app/views/empleados/index.html.erb
create app/views/empleados/show.html.erb
create app/views/empleados/new.html.erb
create app/views/empleados/edit.html.erb
create app/views/layouts/empleados.html.erb
create public/stylesheets/scaffold.css
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
identical app/models/empleado.rb
identical test/unit/empleado_test.rb
identical test/fixtures/empleados.yml
exists db/migrate
Another migration is already named create_empleados:
db/migrate/001_create_empleados.rb

C:\InstantRails\rails_apps\empresa>ruby script/generate controller
Empleados
exists app/controllers/
exists app/helpers/
exists app/views/empleados
exists test/functional/
create app/controllers/empleados_controller.rb
create test/functional/empleados_controller_test.rb
create app/helpers/empleados_helper.rb

C:\InstantRails\rails_apps\empresa>

END

I know that there are a few of these floating around, but our area
Ruby Brigade posted a Rails 2 cheatsheet that might help:
http://upstaterb.org/2008/2/14/rails-2-0-cheat-sheet

On Feb 15, 7:45 am, comopasta Gr [email protected]

AndyV wrote:

I know that there are a few of these floating around, but our area
Ruby Brigade posted a Rails 2 cheatsheet that might help:
http://upstaterb.org/2008/2/14/rails-2-0-cheat-sheet

On Feb 15, 7:45 am, comopasta Gr [email protected]

Thanks Andy that is a great summary of changes.

Cheers!