Re: [cfwheels] trouble with basic CRUD from cfwheels.org tutorial

139 views
Skip to first unread message

Chris Peters

unread,
Jun 28, 2012, 12:07:19 PM6/28/12
to cfwh...@googlegroups.com
Did you run the DBMigrate scripts? Click the DBMigrate link in the footer.

Also, read up on how the plugin works.
http://cfwheels.org/plugins/listing/28 

On Thu, Jun 28, 2012 at 11:51 AM, Colin <ma.d...@gmail.com> wrote:
Hi, all -- I'm excited about this framework, having just learned enough Ruby on Rails to be dangerous. But I'm having trouble with setting up a basic users table as outlined on the cfwheels.org site. I'm running Coldfusion 9 on a Linux server, talking to Microsoft SQL Server 2012 Express. Wheels is installed in a directory called 'cfw', and my datasource has the same name and verifies. Once I've followed all the directions and attempt to visit the 'new' action I get:

Wheels.TableNotFound

The users table could not be found in the database.

Suggested action

Add a table named users to your database or tell Wheels to use a different table for this model. For example you can tell a usermodel to use a table called tbl_users by creating a User.cfc file in the models folder, creating an init method inside it and then callingtable("tbl_users") from within it.

Error location

Line 5 in controllers/Users.cfc


3: 
4: 	<cffunction name="new" access="package" output="false" returntype="void">
5: 		<cfset user = model("user").new()>
6: 		<cfreturn />
7: 	</cffunction>

--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfwheels/-/1P627lOx3_kJ.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.

Tom Avey

unread,
Jun 28, 2012, 2:20:56 PM6/28/12
to cfwh...@googlegroups.com
Try to capitalize User in the model call.

Colin

unread,
Jun 28, 2012, 3:07:24 PM6/28/12
to cfwh...@googlegroups.com
I did it in my Users controller, the 'new' method, but it didn't work.

Colin

unread,
Jun 28, 2012, 3:09:41 PM6/28/12
to cfwh...@googlegroups.com
I haven't installed DBMigrate. Was I supposed to? I just created the users table manually.


On Thursday, June 28, 2012 12:07:19 PM UTC-4, Chris Peters wrote:
Did you run the DBMigrate scripts? Click the DBMigrate link in the footer.

Also, read up on how the plugin works.
On Thu, Jun 28, 2012 at 11:51 AM, Colin wrote:
Hi, all -- I'm excited about this framework, having just learned enough Ruby on Rails to be dangerous. But I'm having trouble with setting up a basic users table as outlined on the cfwheels.org site. I'm running Coldfusion 9 on a Linux server, talking to Microsoft SQL Server 2012 Express. Wheels is installed in a directory called 'cfw', and my datasource has the same name and verifies. Once I've followed all the directions and attempt to visit the 'new' action I get:

Wheels.TableNotFound

The users table could not be found in the database.

Suggested action

Add a table named users to your database or tell Wheels to use a different table for this model. For example you can tell a usermodel to use a table called tbl_users by creating a User.cfc file in the models folder, creating an init method inside it and then callingtable("tbl_users") from within it.

Error location

Line 5 in controllers/Users.cfc

3: 
4: 	<cffunction name="new" access="package" output="false" returntype="void">
5: 		<cfset user = model("user").new()>
6: 		<cfreturn />
7: 	</cffunction>

--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfwheels/-/1P627lOx3_kJ.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+unsubscribe@googlegroups.com.

Tom Avey

unread,
Jun 29, 2012, 9:23:12 AM6/29/12
to cfwh...@googlegroups.com
I've learned to be really careful about the case of method cfc's and calls to the method from a controller on a linux server  And even then to appeared to take a few reloads before it took.

Make sure the table is named User, the method is named "User.cfc" and in controller is

<cfset user = model("User").new()>
BTW - I'm not totally sure why, but sometimes a simple reload=true is not enough.  I have to do reload=development and then reload = production.

Andy Bellenie

unread,
Jun 29, 2012, 9:27:39 AM6/29/12
to cfwh...@googlegroups.com
Didn't someone else have an issue with SQL 2012?

--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfwheels/-/zLKdIbRezeMJ.

Colin

unread,
Jun 29, 2012, 12:03:15 PM6/29/12
to cfwh...@googlegroups.com
Hmmm ... I changed everything to Users (capitalized), including the database schema, and got the error that the table "Users" couldn't be found. I also tried inserting dbo.users, to comply with sql server's owner scheme, but that didn't help either, got "dbo.users" could not be found.

Colin

unread,
Jun 29, 2012, 12:31:49 PM6/29/12
to cfwh...@googlegroups.com
There was this -- CFWheels 1.1.8 incompatible with Railo 3.3 and MS SQL Server 2012

But that sounded like Railo 3.3. didn't have a driver compatible with SQL Server 2012. From what I can tell, Coldfusion 9 has no such compatibility problems.


On Friday, June 29, 2012 9:27:39 AM UTC-4, Andy Bellenie wrote:
Didn't someone else have an issue with SQL 2012?
On 29 June 2012 14:23, Tom Avey wrote:
I've learned to be really careful about the case of method cfc's and calls to the method from a controller on a linux server  And even then to appeared to take a few reloads before it took.

Make sure the table is named User, the method is named "User.cfc" and in controller is

<cfset user = model("User").new()>
BTW - I'm not totally sure why, but sometimes a simple reload=true is not enough.  I have to do reload=development and then reload = production.




On Thursday, June 28, 2012 3:07:24 PM UTC-4, Colin wrote:
I did it in my Users controller, the 'new' method, but it didn't work.

On Thursday, June 28, 2012 2:20:56 PM UTC-4, Tom Avey wrote:
Try to capitalize User in the model call.

--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfwheels/-/zLKdIbRezeMJ.

To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+unsubscribe@googlegroups.com.

Colin

unread,
Jun 29, 2012, 12:43:58 PM6/29/12
to cfwh...@googlegroups.com
I should also add that I am serving it up from a subfolder like this: http://127.0.0.1:8500/cfw/index.cfm/users/new?reload=true

Colin

unread,
Jun 29, 2012, 12:50:59 PM6/29/12
to cfwh...@googlegroups.com
And a test page shows that at least basic select queries work against the database (standalone file, not via wheels).

Colin

unread,
Jun 29, 2012, 1:10:40 PM6/29/12
to cfwh...@googlegroups.com
Wait, it shouldn't be looking for the users table at all. I'm hitting the new page, whose controller is below. That shouldn't write to or read from the db, should it?

<cffunction name="new">


<cfset user = model("User").new()>

</cffunction>

Colin

unread,
Jun 29, 2012, 1:13:54 PM6/29/12
to cfwh...@googlegroups.com
Looks like it's querying the table so it will know what fields should belong to the object.

tpet...@gmail.com

unread,
Jun 29, 2012, 1:22:46 PM6/29/12
to cfwh...@googlegroups.com
hmmm.... what happens if you just do a straight cfquery instead of going through the orm? does it hit the table then?

<cffunction name="new">

<cfquery name="#users#" datasource="#application.wheels.datasource#">
select * from users
</cfquery>
<cfdump var="#users#"><cfabort>

</cffunction>

this will at least let you know if your datasource is setup correctly.

tpet...@gmail.com

unread,
Jun 29, 2012, 1:23:49 PM6/29/12
to cfwh...@googlegroups.com
my cut and paste skillz suck :)

<cffunction name="new">

<cfquery name="users" datasource="#application.wheels.datasource#">
select * from users
</cfquery>
<cfdump var="#users#"><cfabort>

</cffunction>

Colin

unread,
Jun 29, 2012, 1:53:55 PM6/29/12
to cfwh...@googlegroups.com
I had to replace #application.wheels.datasource# with #get('datasourcename')# , but once I did I got a different error message, [Macromedia][SQLServer JDBC Driver][SQLServer]The SELECT permission was denied on the object 'users', database 'cfw_xreg', schema 'dbo'. I'll see what's up with the permissions.

Colin

unread,
Jun 29, 2012, 2:00:05 PM6/29/12
to cfwh...@googlegroups.com
Hey! That was it. Querying the database explicitly revealed a permissions problem. Once I gave my db login db_owner permissions, it was able to run the explicit query, and then able to run the original function. Unhelpful error message though, "users table could not be found." I wonder if, when wheels polls the database for objects, SQL Server returns an empty set of table names if you have no permissions on any of them. That would be hard for wheels to understand and give a good error message, if that's the case. 

Thanks for the help!

Andy Bellenie

unread,
Jun 29, 2012, 2:09:39 PM6/29/12
to cfwh...@googlegroups.com
That's exactly what happens. Wheels makes a <cfdbinfo> call to get all the database information, but if your permissions aren't set correctly, then it doesn't see the table.

You're right though, we could probably improve the error message.

Glad you've got it working :)


--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfwheels/-/oTvs_IBkqXwJ.

To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.

tpet...@gmail.com

unread,
Jun 29, 2012, 3:32:36 PM6/29/12
to cfwh...@googlegroups.com
colin,

i'm glad you were able to get the problem solved. To be honest, i haven't a clue what the error message returned from dbinfo. I'll have to look into this and maybe just bubble up the error that we catch.
To unsubscribe from this group, send email to cfwheels+unsubscribe@googlegroups.com.

Chris Peters

unread,
Jul 2, 2012, 10:38:05 AM7/2/12
to cfwh...@googlegroups.com
I just realized that you were talking about another tutorial. I was thinking about the screencasts. There are DBMigrate scripts along with the newer screencast episodes.

Sorry about any confusion that I introduced with that brain fart.
Reply all
Reply to author
Forward
0 new messages