Create 'edit email address' functionality in rails - ruby-on-rails-3

I am working on rails framework and want to create 'edit email address' functionality for user so that user can easily change its email address.but I have no idea how can I create that functionality. Please give some idea.Thanks in advance.

create a 'crud' controller for the model that has email as its field. u can edit the email in 'edit' form. see http://guides.rubyonrails.org/getting_started.html

Related

Is there any way to allow admin to edit the user password in Orchard CMS?

Is there an extension i can use to allow the admin to edit the user password in orchard? Because, when i go to Settings>Users>Edit User, i have options only to change the user name, email or roles?
And if no there are no extensions in the gallery, any suggestions how to custom do it?
Thank you in advance.
I have used the Change Password module from Gallery. It lets you change passwords to every user and show a new tab in the Users category.

How to manually create reset password token using devise

I am developing a Rails 3.2 app. When a user signs up or when I create a user account in my admin panel, a welcome email is sent to them. I want to include a link on which the user can click to get to the password reset page (where they can set/change their password).
So what I want to do basically is to manually create a reset password token, create a link to the reset password page (where they select a new password) and include it in the welcome email. I do not want to send two emails (welcome and reset password).
I guess some of this code could be used but I do not know how.
https://github.com/plataformatec/devise/blob/master/lib/devise/models/recoverable.rb
How can I do this?
Thankful for all help!
Just had to do something similar to this and thought I'd post an answer if someone stumbles on this. Assuming you have devise correctly set up, all you need to do is make sure the user exists in the database and then redirect to the devise route. I leveraged their code here: goo.gl/cE5USm.
def password_reset_controller
user = User.find_by_email( params[:email] )
if user
redirect_to password_path(:user, email: user.email)
else
# do something different
end
end
In console if you call password_path(:user, email: user.email) -> "/users/password?email='email'"
Edit:
Alternatively, you can just use user.send_reset_password_instructions from goo.gl/aPQ8MU

Avoid Sending Email when User Post New Listing

I am new to OSClass, right now when user publish a listing an email has been sent to user's email id, in which user can activate that listing, admin can also activate that listing.
But I want that only admin should have control to activate the listing, so if somehow I can control that if I skip that step of sending email to user's email account.
Is there any solution?
Regards.
You can remove the email sending removing the hooks.
Edit your oc-load.php file and add this lines:
osc_remove_hook('hook_email_new_item_non_register_user', 'fn_email_new_item_non_register_user');
osc_remove_hook('hook_email_item_validation_non_register_user', 'fn_email_item_validation_non_register_user');
osc_remove_hook('hook_email_item_validation', 'fn_email_item_validation');
If you doubts of hooks you can take a look at http://doc.osclass.org/Hooks
you can create a plugin for this and this way you don't modify the osclass core files, you can check how here http://doc.osclass.org/How_to_create_a_plugin

Sending a custom email with Rails?

I have a site called www.mystorkparty.com where you can build a registry for your baby-shower.
Now I want to add a link so a user can email there registry link to friends.
I can use html and create a link that opens there email program - but how do I put in a the specific registry URL in automatically. Or should I do an internal email setup rather and send from my the site itself.
Whats the best option?
Thanks in advance.
You can make use of the mail_to helper for this. The mail_to helper allows you to specify a number of paramters such as :subject and :cc as optional arguments to pre-fil the link. You can also obfusicate the link using a number of options such as javascript or hex encoding.
An example link is similar to the link to method but looks like this:
mail_to "me#domain.com", "My email", :cc => "ccaddress#domain.com", :subject => "This is an example email"
This will create a mailto: link that will open the users default email client with the relevant values filled in.

collect email using hominid/mailchimp rails 3.0

I would like to collect emails of prospective users of my app. I've created a page with a simple form. My first question is that since I'm not using a db, do I need a model? And secondly, how do I use "form_for" for form generation if I don't need to use a model. Thank you
I've done this. First I created a simple form with an email field and submit button in my views (app/views/home.html.erb). I use form tag helper to easily create the form rather than writing my own html: http://guides.rubyonrails.org/form_helpers.html. I made sure route the form action to the correct action in my controller. In the controller I use hominid to do the subscription, then redirect to the index using redirect_to (':action => home'). That's all it took.