collect email using hominid/mailchimp rails 3.0 - ruby-on-rails-3

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.

Related

submit form data to custom page for emailing

I created a custom form on a shopify page and when the submit button is pressed i want all the data within the form fields to go to another page that is a request form where the user would enter data and upon submission the data will be emailed instead of buying anything. How is this done in shopify? the page that i'm talking about is this one
https://pharaohmfg.com/collections/billiard-pool-tables/products/luxor-pool-table
You can redirect to another page with a custom form but the email will not be send since you are required to use /contact#contact_form as the form action.
One way to bypass that is to submit the form as a contact form and redirect the user upon form success. Please note that this way if you submit the form more than once you will get a google challenge for spam protection which is not user friendly.
Another way is to create a custom APP and using a proxy to submit to that page and handle the request from there.
Or an another option is to use a third party app of some sort and use their form builder ( hopefully allowing you to tie the product variants in some way to the actual form ).
There are free services like formspree that allows direct submissions to an email but I don't know what are the limits there.

Sitefinity Feather custom action form

I've got the following problem: in Sitefinity (9.1, Feather) I need a form, which can call 3rd party API (Mandrill) once submitted.
As far as I understand, I need some kind of custom widget or something.
Any help would be very appreciated.
Thanks
I would start here. You don't necessarily have to create a separate class library for creating the custom Feather widget (you can just put it in the SitefinityWebApp web project), but you can if you like. With Feather/MVC widgets you basically get a Controller and View, with an optional Model class to play with too.
In your scenario, you'd probably have a Controller with two actions: Display the form, and handling the form submission. In your form submit action you'd then call Mandrill to submit the data (or do whatever it is you need to do). In your Controller you're in C# purely, so you can do whatever you like there.

Would like to add some custom ajax & javascript to activeadmin based application

Hi guys I'm working on this application using activeadmin. I've come to a point where I would like to add in some ajax based functions. I have the basic form set up using teh activeadmin resource and it generates a very pretty form.
I would like to while the user is entering the details on the form - run a ajax call which would retrieve some html based on the values being entered and populate it on the page.
More likely I would like a way to add custom javascript to the page. Whats the best way to do this - I'm facing issues with returning html without the entire activeadmin layout coming with it.
You can use the /config/initializers/active_admin.rb
You can add javascript resources like this:
config.register_javascript 'my_functions.js'
I use to put code directly to /app/assets/javascripts/active_admin.js
You can also include script in /config/initializers/active_admin.rb

Using ajax for rails image preview in form

I've been working on this issue for about two days now. I've posted more task specific questions, got great answers, only to figure out the approach I was taking wouldn't work.
Basically, I want a user to be able to upload images in a form and see a preview of the image they upload before submitting the form. The images and the parent form have a has_many relationship. The images are nested in the parent form using fields_for.
I tried using a client side approach, but ran into cross browser and security issues. My current approach I'm trying is to save the images, reload the div portion of the page, and then assign the parent_id to the image after the partent form is submitted (since I will not have a id for the partent form until it is created).
Is it possible to use ajax to submit the fields_for portion of a form and not the entire parent form? Has anyone attempted to do something similar?
Of course you can submit only the fields of that image by using jQuery to select only the fields that you want to send, serialize them and send them as data of the ajax request.
Be careful, you need to send the authtoken, that's why I have type=hidden in the selector
var data = form.find('[name*=image],[type=hidden]').not('[name*=items]').serialize();
$.ajax({url: this.form.attr('action'), context: this, type: 'POST', data: data
The next step with the image I once implemented as storing the in their own database table, returning the client the id to that who then adds it to the form.

Rails/Devise: How to modiy the controller for /users/edit?

I use Devise and right now /users/edit contains only Devise's password change form. I want to add a user settings form.
I am new to Rails, what is the best way to do this?
The view for /users/edit seems to be in /app/views/devise/passwords/edit.html.erb.
The controller for /users/edit is nowhere to be found. How to extract it from Rails's magic so that I can modify it?
The appropriate view is app/views/devise/registrations/edit.html.erb. You dont need controller to add additional fields into the registrations form, even if its a nested form fields of another model. Just make appropriate changes in your User model to save nested associations (accepts_nested_attributes_for), attr_accessible etc.