Search code examples
ruby-on-railsmodel-view-controllerrestrestful-authentication

RESTful (or proper) MVC design for Landing Page with Rails


I've got a very simple question around Rails MVC/application design with a focus on being RESTful. I'm very, very new to Rails; this is in fact the first application I'm building on my own (though I've gone through Michael Hartl's Rails Tutorial and Rails for Zombies 1 & 2).

Goal: I want to create a single page that collects email addresses - something very very similar to early Mint prototypes, wherein before building their app they used a landing page to evaluate interest in the idea and test potential marketing messages.

Approach: My first instinct is to create a LandingPages controller and an Email model, and this actually worked very well until I got to the email collection form - at that point, I hit a bunch of snags writing Rspec tests and then application code.

Most of my troubles were around assigning the form, which was served by the LandingPages controller and view, but of course submitted data to the Email model.

Question: Is the two-model approach I suggested above appropriate? Or should I consolidate everything in to one Email(s) model & controller scheme? Might the separate be what caused my application code to get more complex, because I had Controller A interacting with Model B?

If the Approach above is appropriate, I will submit my actual code questions in another form. :)

Thanks!


Solution

  • For sake of RESTfulness your form at the LandingPageController should point to EmailController#create. But no one will die if you don't do it that way.

    What are the two models?