[Rails] Problems occur during production, but not in development

1 view
Skip to first unread message

Joe

unread,
May 16, 2010, 3:27:16 AM5/16/10
to Ruby on Rails: Talk
Hi,

Basically I've created a system with categories, that belong to
tutorials, and these tutorials have positions.
I've only recently created to new position thing, and I've added this
to my edit form:

<p>
<%= f.label :position %><br />
<%= f.text_field :position %>
</p>

This works fine in production mode, and everything is as it should be.
However when I upload it to my actual site (so it goes to production
mode) it says an error has occured. And the production log gives out
this error:

ActionView::TemplateError (undefined method `position' for #<Tutorial:
0xb752a384>) on line #21 of app/views/tutorials/edit.html.erb:
18: </p>
19: <p>
20: <%= f.label :position %><br />
21: <%= f.text_field :position %>
22: </p>
23: <p>
24: <%= f.submit 'Update' %>

app/views/tutorials/edit.html.erb:21
app/views/tutorials/edit.html.erb:4


Since it mentions line four, I figured I should show you guys line
four as well:

<% form_for(@tutorial) do |f| %>

I don't know why it wont work. Everything else that's like this works,
for example the category_id:

<p>
<%= f.label :category_id %><br />
<%= f.text_field :category_id %>
</p>


I just can't figure out why it won't work,

Please Help,

Thanks In Advance,

Joe

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Colin Law

unread,
May 16, 2010, 3:37:14 AM5/16/10
to rubyonra...@googlegroups.com
On 16 May 2010 08:27, Joe <j...@dev-hq.co.uk> wrote:
> Hi,
>
> Basically I've created a system with categories, that belong to
> tutorials, and these tutorials have positions.
> I've only recently created to new position thing, and I've added this
> to my edit form:
>
>  <p>
>    <%= f.label :position %><br />
>    <%= f.text_field :position %>
>  </p>
>
> This works fine in production mode, and everything is as it should be.

I guess you meant ok in development.

> However when I upload it to my actual site (so it goes to production
> mode) it says an error has occured. And the production log gives out
> this error:
>
> ActionView::TemplateError (undefined method `position' for #<Tutorial:
> 0xb752a384>) on line #21 of app/views/tutorials/edit.html.erb:
> 18:   </p>
> 19:     <p>
> 20:     <%= f.label :position %><br />
> 21:     <%= f.text_field :position %>
> 22:   </p>
> 23:   <p>
> 24:     <%= f.submit 'Update' %>
>
>    app/views/tutorials/edit.html.erb:21
>    app/views/tutorials/edit.html.erb:4

Did you remember to run the migration on the production db so that the
new column is there?

Colin

Joe

unread,
May 16, 2010, 5:47:20 AM5/16/10
to Ruby on Rails: Talk
I did mean OK in development.

And as for running the migration on production. I wasn't even aware I
could do that. I just run rake db:migrate.

How can I run the migration on production? (I'll be googling while
waiting for a reply :P),

Thanks for your help,

-Joe

Joe

unread,
May 16, 2010, 5:50:19 AM5/16/10
to Ruby on Rails: Talk
Ok. Found it out and it works.

Thanks for your help, I can't belive I didn't even know about
migrating in production mode (I remember I had the problem before, but
couldnt remember how I fixued it (must have been via this method)).

If anyone wants to know how: rake db:migrate RAILS_ENV="production"

Thanks so much!

-Joe

Marnen Laibow-Koser

unread,
May 16, 2010, 11:02:39 AM5/16/10
to rubyonra...@googlegroups.com
Joe wrote:
> Ok. Found it out and it works.
>
> Thanks for your help, I can't belive I didn't even know about
> migrating in production mode (I remember I had the problem before, but
> couldnt remember how I fixued it (must have been via this method)).
>
> If anyone wants to know how: rake db:migrate RAILS_ENV="production"

Better yet, set up Capistrano, which automates this and most other
deployment tasks.

>
> Thanks so much!
>
> -Joe

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org


--
Posted via http://www.ruby-forum.com/.
Reply all
Reply to author
Forward
0 new messages