# How did I end up with read-only access?

**URL:** <https://www.ruby-forum.com/t/how-did-i-end-up-with-read-only-access/53300>\
**Category:** Rails\
**Created:** [January 31, 2006, 7:21pm UTC](https://www.ruby-forum.com/t/how-did-i-end-up-with-read-only-access/53300 "2006-01-31T19:21:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Duane](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b4bc9f/32.png) [@Duane](https://www.ruby-forum.com/u/Duane)\
**Post date:** [January 31, 2006, 7:21pm UTC](https://www.ruby-forum.com/t/how-did-i-end-up-with-read-only-access/53300/1 "2006-01-31T19:21:19Z")

</div>

I’ve generated the standard scaffolding half a dozen times on play  
databases on my own machine, but now I’m trying it for real against the  
team’s development database (postgres) and I see to have ended up in  
some sort of read-only mode. “list” will show my existing records and  
“show” will drill down, as expected, but “New” or “Edit” just show a  
blank screen with a New/Edit button - no empty (or populated) form  
fields to fill in.

I really have no idea how that might have happened. I did all the usual  
script/generate scaffold emailtemplate thing, created table  
emailtemplates in my database with an id field, and so on.

Anybody seen that one before? the only other thing I can think that’s  
changed is this is the first time I’m using rails 1.x, previous attempts  
were prior to the official 1.0 launch.

Duane

---

<div class="post-metadata">

**Author:** ![Duane](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b4bc9f/32.png) [@Duane](https://www.ruby-forum.com/u/Duane)\
**Post date:** [January 31, 2006, 7:26pm UTC](https://www.ruby-forum.com/t/how-did-i-end-up-with-read-only-access/53300/2 "2006-01-31T19:26:01Z")

</div>

I see that my app/view/email/\_form.rhtml file contains only this:

\<%= error\_messages\_for ‘emailtemplate’ %\>

which is probably a big part of the problem. But the scaffold command  
did not give any hint of a problem:

[root@trump admin]# script/generate scaffold emailtemplate Email  
exists app/controllers/  
exists app/helpers/  
exists app/views/email  
exists test/functional/  
dependency model  
exists app/models/  
exists test/unit/  
exists test/fixtures/  
skip app/models/emailtemplate.rb  
identical test/unit/emailtemplate\_test.rb  
identical test/fixtures/emailtemplates.yml  
create app/views/email/\_form.rhtml  
create app/views/email/list.rhtml  
create app/views/email/show.rhtml  
create app/views/email/new.rhtml  
create app/views/email/edit.rhtml  
create app/controllers/email\_controller.rb  
create test/functional/email\_controller\_test.rb  
create app/helpers/email\_helper.rb  
create app/views/layouts/email.rhtml  
identical public/stylesheets/scaffold.css

Any ideas? What data, specific to my app, does the scaffold generator  
even look at? I though the \_form file just generically said “Get the  
columns in the database and display a field for each of them associated  
with the column name”.

Duane wrote:

> I’ve generated the standard scaffolding half a dozen times on play  
> databases on my own machine, but now I’m trying it for real against the  
> team’s development database (postgres) and I see to have ended up in  
> some sort of read-only mode. “list” will show my existing records and  
> “show” will drill down, as expected, but “New” or “Edit” just show a  
> blank screen with a New/Edit button - no empty (or populated) form  
> fields to fill in.
> 
> I really have no idea how that might have happened. I did all the usual  
> script/generate scaffold emailtemplate thing, created table  
> emailtemplates in my database with an id field, and so on.
> 
> Anybody seen that one before? the only other thing I can think that’s  
> changed is this is the first time I’m using rails 1.x, previous attempts  
> were prior to the official 1.0 launch.
> 
> Duane

---

<div class="post-metadata">

**Author:** ![Duane](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b4bc9f/32.png) [@Duane](https://www.ruby-forum.com/u/Duane)\
**Post date:** [January 31, 2006, 7:33pm UTC](https://www.ruby-forum.com/t/how-did-i-end-up-with-read-only-access/53300/3 "2006-01-31T19:33:51Z")

</div>

Found it, and let me just say “ew”.

As folks may know, the scaffold generator does not play nicely with  
set\_table\_name now, if you’re using it. Even if you plan to use a table  
of an unexpected name, which you can do, it will still look for  
emailtemplates or whatever during generation time. The solution is easy

- just create an empty table with the expected name.

Nope, and that’s my problem. The \_form was looking at that empty table,  
and of course seeing nothing. Funny, too, since “list” executes at  
runtime and properly responds to set\_table\_name, so it would see the  
columns that exist in the desired table, but \_form was empty because it  
had nothing to iterate over.

Solution - you need a properly named and properly setup table to exist  
before running the scaffold generator.

Duane wrote:

> I see that my app/view/email/\_form.rhtml file contains only this:
> 
> \<%= error\_messages\_for ‘emailtemplate’ %\>
> 
> which is probably a big part of the problem. But the scaffold command  
> did not give any hint of a problem:
> 
> [root@trump admin]# script/generate scaffold emailtemplate Email  
> exists app/controllers/  
> exists app/helpers/  
> exists app/views/email  
> exists test/functional/  
> dependency model  
> exists app/models/  
> exists test/unit/  
> exists test/fixtures/  
> skip app/models/emailtemplate.rb  
> identical test/unit/emailtemplate\_test.rb  
> identical test/fixtures/emailtemplates.yml  
> create app/views/email/\_form.rhtml  
> create app/views/email/list.rhtml  
> create app/views/email/show.rhtml  
> create app/views/email/new.rhtml  
> create app/views/email/edit.rhtml  
> create app/controllers/email\_controller.rb  
> create test/functional/email\_controller\_test.rb  
> create app/helpers/email\_helper.rb  
> create app/views/layouts/email.rhtml  
> identical public/stylesheets/scaffold.css
> 
> Any ideas? What data, specific to my app, does the scaffold generator  
> even look at? I though the \_form file just generically said “Get the  
> columns in the database and display a field for each of them associated  
> with the column name”.
> 
> Duane wrote:
> 
> > I’ve generated the standard scaffolding half a dozen times on play  
> > databases on my own machine, but now I’m trying it for real against the  
> > team’s development database (postgres) and I see to have ended up in  
> > some sort of read-only mode. “list” will show my existing records and  
> > “show” will drill down, as expected, but “New” or “Edit” just show a  
> > blank screen with a New/Edit button - no empty (or populated) form  
> > fields to fill in.
> > 
> > I really have no idea how that might have happened. I did all the usual  
> > script/generate scaffold emailtemplate thing, created table  
> > emailtemplates in my database with an id field, and so on.
> > 
> > Anybody seen that one before? the only other thing I can think that’s  
> > changed is this is the first time I’m using rails 1.x, previous attempts  
> > were prior to the official 1.0 launch.
> > 
> > Duane
