0% found this document useful (0 votes)
11 views

MVC Web Framework

The document describes the MVC framework structure for a web application. It lists the main components as the app, controllers, helpers, models, views, layouts, config, environments, initializers, db, documentation, libraries, tasks, logging, public assets like stylesheets and images, scripts, and testing code. It then provides examples of model, view, and controller code for a user profile implementation. Finally, it briefly explains scaffolding and ActiveRecord for model handling in Ruby on Rails.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

MVC Web Framework

The document describes the MVC framework structure for a web application. It lists the main components as the app, controllers, helpers, models, views, layouts, config, environments, initializers, db, documentation, libraries, tasks, logging, public assets like stylesheets and images, scripts, and testing code. It then provides examples of model, view, and controller code for a user profile implementation. Finally, it briefly explains scaffolding and ActiveRecord for model handling in Ruby on Rails.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

MVC web framework

❑ app: The dynamic portion of your web application


❑ controllers: The interface and business logic
❑ helpers: Supporting code for your views
❑ models: The model objects persisted to your DB and used in your application
❑ views: Templates for the responses sent back to remote users
❑ layouts: Page layout files
❑ config: Environment, database, and application configuration
❑ environments: Environment-specific configuration
❑ initializers: Configuring files to be parsed at server startup
❑ db: Your database schema as a set of ActiveRecord migrations
❑ *doc: Documentation for your web application
❑ *lib: Any Ruby libraries specific to your web application
❑ tasks: Project-specific rake tasks
❑ log: Logging output
❑ public: The static portion of your web application
❑ stylesheets:: Your CSS files
❑ javascripts: Your JavaScript files
❑ images: Your image files
❑ *script: Shell scripts to manage your Rails project
❑ *test: All the testing code and data for your application
❑ fixtures: Database data to be preloaded during testing
❑ functional: Functional tests to verify correctness of your controllers
❑ integration: Integration tests
❑ mocks: Mock objects for testing use
❑ unit: Unit tests to verify correctness of your models
❑ tmp: A place for Rails to store its temporary data
❑ vendor: External libraries used by your application
❑ plugins: Rails plug-ins

Model View Controller


What The Objects The set of HTML The code that accepts web
representing the template, CSS style, requests, manipulates the
web domain of the and JavaScript code model, and renders a view
web that creates the user to send back to the user
application.These experience on a web
objects site
encapsulates tables
in a database
Example User A user’s profile page An account controller to
Post A blog article manage sign-ups, sign-
Comment An “add comment” ins, and last password
Auction form
Photo An auction detail
page
A photo thumbnail
Language Ruby/PHP/Java/etc. HTML, CSS, Ruby/PHP/Java/etc.
For object Javascript
representation SQL
For object
persistence

Scaffold

Create
Function Purpose Function Body
New Display the form for a new @user = User.new
User object
create Accepts request data and attempts to @user =
create a new User object User.new(params[:user])
if @user.save
flash[:notice] =
’User was successfully
created.’
redirect_to
user_url(@user)
else
render :action => "new"
end.

ActiveRecord (the Model)

ActiveRecord is designed to handle all of an application’s tasks that relate to the


database, including:

← establishing a connection to the database server


← retrieving data from a table
← storing new data in the database

ActiveRecord also has a few other neat tricks up its sleeve. Let’s look at some of
them now.(sitepoint)

You might also like