Rails 2.0 deprecated warning

Hi

I am on Rails 1.2.6, but want to get my app running without warning’s
so i can move to 2.0.2.

I’m currently getting the folowing warning:

“has_avatar? is deprecated and will be removed from Rails 2.0 (use !
avatar insead)”

This is my view code:

<% if @user.has_avatar? %>

<p>You already have an Avatar!</p>

<% else %>

<h2>Upload Avatar:</h2>
<%= error_messages_for :avatar %>

<% form_for(:avatar, :url => user_avatars_path,
:html => { :multipart => true }) do |f| -%>


Select File:
<%= f.file_field :uploaded_data %>



<%= submit_tag ‘Add Avatar’ %>


<% end -%>

<% end %>

I am not sure how to modify the code correctly.

Any help appreciated…

PJ.

Can you copy and paste the exact error please with any backtrace

On Jan 14, 2008 2:20 PM, PJAY79 [email protected] wrote:

<% end %>

I am not sure how to modify the code correctly.

Any help appreciated…

PJ.


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.

Hi Ryan, this is the output i get from the console, it’s not really an
error, everything actually works, i just want it to work without
getting the deprecated warning!

Processing AvatarsController#new (for 127.0.0.1 at 2008-01-14
21:13:37) [GET]
Session ID: e78fd9233bca38db1b5474e1aa067236
Parameters: {“action”=>“new”, “controller”=>“avatars”,
“user_id”=>“1”}
[4;36;1mAvatar Columns (0.017000) [0m [0;1mSHOW FIELDS FROM
avatars [0m
[4;35;1mUser Columns (0.009000) [0m [0mSHOW FIELDS FROM
users [0m
[4;36;1mUser Load (0.005000) [0m [0;1mSELECT * FROM users WHERE
(users.id = 1) LIMIT 1 [0m
[4;35;1mUser Load (0.000000) [0m [0mSELECT * FROM users WHERE
(users.id = 1) [0m
Rendering within layouts/cool
Rendering avatars/new
DEPRECATION WARNING: has_avatar? is deprecated and will be removed
from Rails 2.0 (use !avatar insead) See

for details. (called from _run_rhtml_47app47views47avatars47new46rhtml
at C:/InstantRails/rails_apps/socialnewsone/app/views/avatars/
new.rhtml:1)
[4;36;1mAvatar Load (0.001000) [0m [0;1mSELECT * FROM avatars
WHERE (avatars.user_id = 1) LIMIT 1 [0m
[4;35;1mRole Columns (0.015000) [0m [0mSHOW FIELDS FROM
roles [0m
[4;36;1mRole Load (0.001000) [0m [0;1mSELECT * FROM roles INNER
JOIN roles_users ON roles.id = roles_users.role_id WHERE
(roles_users.user_id = 1 ) AND (roles.name = ‘Admin’) LIMIT 1 [0m
Completed in 0.44800 (2 reqs/sec) | Rendering: 0.10700 (23%) | DB:
0.04800 (10%) | 200 OK [http://localhost/users/1/avatars/new]

Thanks,

PJ.

On 14 Jan 2008, at 11:01, Daniel W. wrote:

avatar insead)"

That’s a pretty odd deprecation notice. There’s no “avatar” methods in
Rails. Perhaps you have deprecated code inside your has_avatar?
method?
Could you post the contents of that method?

Not really: if you have an association you used to get a has_foo?
method. Rails is telling you that has_foo? is going away and that you
should just test whether foo is nil or not.

Fred

Frederick C. wrote:

Not really: if you have an association you used to get a has_foo?
method. Rails is telling you that has_foo? is going away and that you
should just test whether foo is nil or not.

Ah, interesting. I was not aware of that. Thanks for the heads up.

I do know that Rails gives you #attribute_name? methods. Say User
objects have a name attribute, you get name? returning true is the
object/db contains a non-nil value.

Praveen Jayarajan wrote:

Hi

I am on Rails 1.2.6, but want to get my app running without warning’s
so i can move to 2.0.2.

I’m currently getting the folowing warning:

“has_avatar? is deprecated and will be removed from Rails 2.0 (use !
avatar insead)”

That’s a pretty odd deprecation notice. There’s no “avatar” methods in
Rails. Perhaps you have deprecated code inside your has_avatar? method?
Could you post the contents of that method?

I established the relationship between the User and Avatar models as
follow:

User
has_one :avatar

Avatar
belongs_to :user

That was it really…is it something to do with this…?

PJ.

On Jan 14, 10:01 pm, Daniel W. [email protected]

On 14 Jan 2008, at 11:32, PJAY79 wrote:

and, how do i fix this, in newbie terms…?!

You need to do exactly what the deprecation message says: don’t use
has_avatar?

<% if @user.has_avatar? %>

becomes

<% if @user.avatar %>

and, how do i fix this, in newbie terms…?!

Pj.

Thank you very much Frederick :slight_smile:

PJ.

On Jan 14, 10:45 pm, Frederick C. [email protected]

There are a couple other things deprecated in 2.0 that cause compiler
crashes (although they work in 1.2): namely “@params” and “@request”,
which should be replaced with “params” and “request”.

It’s mentioned in an article here:
http://www.railsrocket.com/migrating-to-rails-20

i want to full coding in on or more project
what about i have lot of things in ruby on rails place help me

i want to full coding in on or more project
what about i have lot of things in ruby on rails place help me

On Jan 14, 4:23 pm, Frederick C. [email protected]

i want to full coding in on or more project
what about i have lot of things in ruby on rails place help me

On Jan 14, 4:23 pm, Frederick C. [email protected]

i want to full coding in on or more project
what about i have lot of things in ruby on rails place help me

Oi want to full coding in on or more project
what about i have lot of things in ruby on rails place help me

i want to full coding in on or more project
what about i have lot of things in ruby on rails place help me

On Jan 14, 4:01 pm, Daniel W. [email protected]

i want to full coding in on or more project
what about i have lot of things in ruby on rails place help me

i want to full coding in on or more project
what about i have lot of things in ruby on rails place help me

i want to full coding in on or more project
what about i have lot of things in ruby on rails place help me

On Jan 14, 4:23 pm, Frederick C. [email protected]