simple-private-messages icon indicating copy to clipboard operation
simple-private-messages copied to clipboard

Installation issues.

Open ingus-t opened this issue 12 years ago • 8 comments

I have followed the instructions and have tried the installation a couple of times now.

Steps I've done: Added plugin to gemfile, ran bundle install rails generate simple_private_messages:model User Pmessage Added this line to user.rb : has_private_messages :class_name => "Pmessage" rails generate simple_private_messages:scaffold User Pmessage Uncommented this line in pmessage.rb : attr_accessor :to

I then added this to my routes.rb : match '/pmessages', to: 'pmessages#index'

Accessing /pmessages results in this error message: ActiveRecord::RecordNotFound in PmessagesController#index Couldn't find User without an ID Rails.root: /home/user/RoR/railsapp app/controllers/pmessages_controller.rb:59:in `set_user'

pmessages controller, set_user method: private def set_user @user = User.find(params[:user_id]) end

Changing that line to @user = User.find(1) and accessing /pmessages results in this error message:

Showing /home/user/RoR/railsapp/app/views/pmessages/_inbox.html.erb where line #26 raised: undefined method `login' for #User:0xab4dc3c Extracted source (around line #26):

Any ideas on what's wrong and how to fix it?

Using Rails 3.2.3

ingus-t avatar May 27 '12 02:05 ingus-t

What are you using for user login and do you have a logged_in? User. Try gem sorcery On 27 May 2012 03:05, "XeroCodeIT" < [email protected]> wrote:

I have followed the instructions and have tried the installation a couple of times now.

Steps I've done: Added plugin to gemfile, ran bundle install rails generate simple_private_messages:model User Pmessage Added this line to user.rb : has_private_messages :class_name => "Pmessage" rails generate simple_private_messages:scaffold User Pmessage Uncommented this line in pmessage.rb : attr_accessor :to

I then added this to my routes.rb : match '/pmessages', to: 'pmessages#index'

Accessing /pmessages results in this error message: ActiveRecord::RecordNotFound in PmessagesController#index Couldn't find User without an ID Rails.root: /home/user/RoR/railsapp app/controllers/pmessages_controller.rb:59:in `set_user'

Changing that line to @user = User.find(1) and accessing /pmessages results in this error message:

Showing /home/user/RoR/railsapp/app/views/pmessages/_inbox.html.erb where line #26 raised: undefined method `login' for #User:0xab4dc3c Extracted source (around line #26):

Any idas on what's wrong and how to fix it?


Reply to this email directly or view it on GitHub: https://github.com/jongilbraith/simple-private-messages/issues/25

safarista avatar May 27 '12 09:05 safarista

I use Devise.

I added an alias in my user.rb model: alias_attribute :login, :name This fixed the "undefined login method" problem.

I also changed @user = User.find(params[:user_id]) to @user = current_user

Now I can access inbox and sent messages, but can't access /users/1/pmessages/new to create a new message. Error message I get is:

undefined method `error_message_on' for #<#Class:0x926d780:0xa017228>

Extracted source (around line #5): 2:

3: To:
4: <%= f.text_field :to %> 5: <%= error_message_on @pmessage, :to %> 6:

7:

8: Subject:

ingus-t avatar May 27 '12 10:05 ingus-t

You will need to select someone you need to send a message to. On line 5 the :to is expecting a user to be passed to it and also uncomment it in your model.

<%= error_message_on @pmessage, :to %>

the url i would expect to see is close to /users/1/pmessages/new?to=2 where ...?to=2 refers to the user.id of the person you are sending the message to. Its used to fetch the that user.

Hope that helps.

On 27 May 2012, at 11:18, XeroCodeIT wrote:

I use Devise.

I added an alias in my user.rb model: alias_attribute :login, :name This fixed the "undefined login method" problem.

I also changed @user = User.find(params[:user_id]) to @user = current_user

Now I can access inbox and sent messages, but can't access /users/1/pmessages/new to create a new message. Error message I get is:

undefined method `error_message_on' for #<#Class:0x926d780:0xa017228>

Extracted source (around line #5): 2:

3: To:
4: <%= f.text_field :to %> 5: <%= error_message_on @pmessage, :to %> 6:

7:

8: Subject:


Reply to this email directly or view it on GitHub: https://github.com/jongilbraith/simple-private-messages/issues/25#issuecomment-5952615

safarista avatar May 27 '12 10:05 safarista

attr_accessor :to was already uncommented in user.rb

If I navigate to http://localhost:3000/users/1/pmessages/1 to show a message (which I added by seeding) and then click on the "Reply" button, it takes me to http://localhost:3000/users/1/pmessages/new?reply_to=1 .

Error message I get is: undefined method `error_message_on' for #<#Class:0x926d780:0xaf2e07c> Extracted source (around line #5):

2:

3: To:
4: <%= f.text_field :to %> 5: <%= error_message_on @pmessage, :to %> 6:

It's the same message I get when I access simply http://localhost:3000/users/1/pmessages/new.

ingus-t avatar May 27 '12 10:05 ingus-t

How many users do yo have in your database? And are you replying/sending message to anyone?

Try and use your own data i.e. users that are on your system. Using device I presume you setup a user authentication maybe on a different model i.e. Person.

You will have to provide a lot more info here. It does not look like you are sending messages to anyone.

safarista avatar May 27 '12 11:05 safarista

A typical example would be:

I am users/1 I go to users/2 and click on a a link "Send me a PMessage " which looks like <%= link_to "Send me a PMessage ", new_user_pmessage_path(@user, :to => @user.id) NOTE this is a new message to user 2

That would give me a url like http://localhost:3000/users/1/pmessages/new?to=2

safarista avatar May 27 '12 11:05 safarista

I'm getting the same error:

undefined method `error_message_on' for #<#Class:0x007f8736aa9230:0x007f8738360878>

Extracted source (around line #5):

2:

3: To:
4: <%= f.text_field :to %> 5: <%= error_message_on @message, :to %> 6:

7:

8: Subject:

I'm algo using Devise gem

isasi88 avatar May 30 '13 14:05 isasi88

The generators are out of date, error_message_on was dropped in Rails 3.

It's more common to roll your own thesedays.

jongilbraith avatar May 30 '13 16:05 jongilbraith