Devise and simple-private-messages implementation - ruby-on-rails

I want to build a user inbox system and choosing this simple-private-messages gem as the backbone. However, the documentation of this gem is rather primitive.
I've generated the scaffold of this gem, however, I don't know what key the gem is used to define the recipient/sender.
I want the current_user is able to message a particular user via the link of its profile page and then it will automatically fill the username into the "to" field.
Would anyone please construct a demo app illustrating the implementation of this gem, thanks a lot.
Please advise.

Related

How to send information from devise user using mailer?

I'm using devise gem and I want to set up a mailer to send information from user to my gmail account and also the user receive a confirmation.
Please be a bit more specific in the first part of your question. What do you exactly want to do?
For the confirmation, the devise gem has a confimrable module which might help you further. Look here: https://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable

Devise: Place a variable in the confirmation email

I am trying to customise the confirmation email in order to pass an extra variable than the resource and confirmation token.
In particular what I want is to get the existing (soon to be overridden) email of the user passed into the confirmation email so that when the user clicks on the confirmation link, the page he goes to will have the user's old email in the parameters.
I'm not sure where I will need to make this change exactly (maybe mailer view or devise mailer?) and also what is the best way to override this in my rails app without touching the devise gem at all?
Or maybe there is even a better way I can get the user's old email after he confirms on the link but, as far as I'm aware, once that happens the old email is gone for good.
Use rails generate devise:views.
This will generate all the views that Devise uses internally so you can make your modifications.
NOTE
This will generate erb templates. If you wish to use haml or anything else. Here is a tutorial on how you can go about this process.

middleman app it is possible to create a contact form?

I have a very basic question.
I have create a simple website with middleman app (a one page website) as portfolio.
Now I would like to add a simple contact form to allow user to contact the admin of the page with this logic:
the user use the contact form on the page
>
the app check the inputs
>
the app create a message and send it to the admin mail box
>
the user receive a confirm message (also it is redirect to a new 'confirm' page)
I know it should be a simple thing to do and there are many tutorails about it, but I am new the rails and mvc logic...
Also on middleman I have no models or 'classic' files as in a rails app, and I am not so sure I could create a contact form on a static middleman app.
Anyone could help me? Or suggest me some specific gems to use or tutorials?
Thanks
Remember that Middleman is a static site generator, but you'll need something dynamic in order to process the form. Pretty much anything will do: a simple PHP script, Rails/Sinatra app, etc., so long as it's running on a server. There are even services like SimpleForm which are pre-built for this purpose.
Once that's set up, simply point your form's action attribute to the address of the processing code. e.g.:
<form method="post" action="http://someserver.com/process_form">

Sending emails by mailer model

I have a database created using Ruby-on-Rails. What I require is a model (perhaps) where I can input some information in a form and then press a button that sends emails to all the users registered in the database. The email contains the details written in the form. Is that possible? Any help will be very appreciated.
Mike
Yes... gather the email addresses in the database. Use the native mailing class for the server technology you are working with. Build the message body as a string (if its a simple email, otherwise you'll want to populate a template file). Create a mail message for whatever server technology you're working with and send to all the gathered emails with the generated body.
Yes yes yes! Rails delivers some great support when it comes to sending emails! using Mailers (you can generate these) all you would need to do is set it up, I would also advice using a gem like mailchimp to test the sent data.
http://guides.rubyonrails.org/action_mailer_basics.html
this tutorial should help you out alot!
Also use your Terminal to fire the Mailers this will make ur process so much faster.
rails console or script/console
rails 2:
MailerClass.deliver_mailer_subclass(passed_parameters)
rails 3:
MailerClass.mailer_subclass(passed_parameters).deliver
Have fun

Authlogic account activation rails

I have a requirement where the user creates an account through form with name and email. I need to send him an activation link once he clicks on it he must be able to choose a password. I am using authlogic please let me know the best way of achieving it.
Authlogic has very comprehensive guide; you can almost copy and paste everything:
https://github.com/binarylogic/authlogic

Resources