SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Architecture Rails:
Controllers: Rails look to find controllers classes. A controllers handles a web request from user.
Views: Holds the display templates to fill in with data from our application, convert to HTML, and
return to the user's browser.
Models: Holds the classes that model and wrap the data stored in our application's database.
Helpers: Holds any helper classes used to assist the model, view, and controllers classes
Methods:
link_to → creates a hyperlink to an action
example: <%= link_to "Hello", say_hello_path %>
Marshaling Objects: Take an object and convert it into a stream of bytes that can be stored outside the
app.
rails generate migration add_columnname_to_tablename columnname:datatype
example: rails generate migration add_password_to_users password:string
Problem Solve Take-note
Get URL parameter path = request.fullpath
path_search = URI.parse(path)
parse_url = CGI.parse(path_search.query)
array_facility_choose = parse_url['search[facilities][]']#params['search']['facilities']
name_facility = Array.new # content all name of facility choose
search[prefecture]=&search[departments][]=3&search[facilities][]=2
To create a model
that references
another, use the
rails model
generator:
$ rails g model wheel car:references
class Wheel < ActiveRecord::Base
belongs_to :car
end
class CreateWheels < ActiveRecord::Migration
def self.up
create_table :wheels do |t|
t.references :car
t.timestamps
end
end
ActiveRecord Products.connection.execute('UPDATE `products` SET `price`=`free` WHERE 1') If the helpers not enough
Rename column script/generate migration rename_my_column_by_hand
Then edit the file it creates:
class RenameMyColumnByHand <
ActiveRecord::Migration
def self.up
rename_column :my_table, :old_name, :new_name
end
def self.down
rename_column :my_table, :new_name, :old_name
end
end
It executes SQL like:
ALTER TABLE my_table CHANGE old_name new_name
BIGINT;
Change type of
column
class AddColumnToTable < ActiveRecord::Migration
def change
add_column :table, :column, :type
end
end
Rails g migration changetypecolumn
Add column rails generate migration add_password_to_users password:string rails generate migration add_columnname_to_tablename
columnname:datatype

Weitere ähnliche Inhalte

Andere mochten auch (6)

Example Mobile Push Notification Service in Rails
Example Mobile Push Notification Service in RailsExample Mobile Push Notification Service in Rails
Example Mobile Push Notification Service in Rails
 
My rails way
My rails wayMy rails way
My rails way
 
Rails 4 & server sent events
Rails 4 & server sent eventsRails 4 & server sent events
Rails 4 & server sent events
 
Action cable
Action cableAction cable
Action cable
 
REST is not enough: Using Push Notifications to better support your mobile cl...
REST is not enough: Using Push Notifications to better support your mobile cl...REST is not enough: Using Push Notifications to better support your mobile cl...
REST is not enough: Using Push Notifications to better support your mobile cl...
 
Mobile Push Notifications
Mobile Push NotificationsMobile Push Notifications
Mobile Push Notifications
 

Ähnlich wie Rails notification

MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 

Ähnlich wie Rails notification (20)

Ruby on rails RAD
Ruby on rails RADRuby on rails RAD
Ruby on rails RAD
 
CodeIgniter 101 Tutorial
CodeIgniter 101 TutorialCodeIgniter 101 Tutorial
CodeIgniter 101 Tutorial
 
Ruby On Rails Siddhesh
Ruby On Rails SiddheshRuby On Rails Siddhesh
Ruby On Rails Siddhesh
 
Ruby on rails3 - introduction to rails
Ruby on rails3 - introduction to railsRuby on rails3 - introduction to rails
Ruby on rails3 - introduction to rails
 
Creating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JSCreating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JS
 
Actionview
ActionviewActionview
Actionview
 
Asp.net With mvc handson
Asp.net With mvc handsonAsp.net With mvc handson
Asp.net With mvc handson
 
How to Create and Load Model in Laravel
How to Create and Load Model in LaravelHow to Create and Load Model in Laravel
How to Create and Load Model in Laravel
 
MVC 4
MVC 4MVC 4
MVC 4
 
Getting into ember.js
Getting into ember.jsGetting into ember.js
Getting into ember.js
 
Web api
Web apiWeb api
Web api
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHP
 
Php.Mvc Presentation
Php.Mvc PresentationPhp.Mvc Presentation
Php.Mvc Presentation
 
Simple mvc4 prepared by gigin krishnan
Simple mvc4 prepared by gigin krishnanSimple mvc4 prepared by gigin krishnan
Simple mvc4 prepared by gigin krishnan
 
Create an application with ember
Create an application with ember Create an application with ember
Create an application with ember
 
Building Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel AppelBuilding Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel Appel
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
MVC 6 Introduction
MVC 6 IntroductionMVC 6 Introduction
MVC 6 Introduction
 

Mehr von baran19901990

Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled Presentation
baran19901990
 

Mehr von baran19901990 (20)

Config websocket on apache
Config websocket on apacheConfig websocket on apache
Config websocket on apache
 
Nhập môn công tác kỹ sư
Nhập môn công tác kỹ sưNhập môn công tác kỹ sư
Nhập môn công tác kỹ sư
 
Tìm đường đi xe buýt trong TPHCM bằng Google Map
Tìm đường đi xe buýt trong TPHCM bằng Google MapTìm đường đi xe buýt trong TPHCM bằng Google Map
Tìm đường đi xe buýt trong TPHCM bằng Google Map
 
How to build a news website use CMS wordpress
How to build a news website use CMS wordpressHow to build a news website use CMS wordpress
How to build a news website use CMS wordpress
 
How to install nginx vs unicorn
How to install nginx vs unicornHow to install nginx vs unicorn
How to install nginx vs unicorn
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled Presentation
 
Control structure
Control structureControl structure
Control structure
 
Subprogram
SubprogramSubprogram
Subprogram
 
Lexical
LexicalLexical
Lexical
 
Introduction
IntroductionIntroduction
Introduction
 
Datatype
DatatypeDatatype
Datatype
 
10 logic+programming+with+prolog
10 logic+programming+with+prolog10 logic+programming+with+prolog
10 logic+programming+with+prolog
 
09 implementing+subprograms
09 implementing+subprograms09 implementing+subprograms
09 implementing+subprograms
 
08 subprograms
08 subprograms08 subprograms
08 subprograms
 
07 control+structures
07 control+structures07 control+structures
07 control+structures
 
How to install git on ubuntu
How to install git on ubuntuHow to install git on ubuntu
How to install git on ubuntu
 
Ruby notification
Ruby notificationRuby notification
Ruby notification
 
Linux notification
Linux notificationLinux notification
Linux notification
 
Lab4
Lab4Lab4
Lab4
 
Lab5
Lab5Lab5
Lab5
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Rails notification

  • 1. Architecture Rails: Controllers: Rails look to find controllers classes. A controllers handles a web request from user. Views: Holds the display templates to fill in with data from our application, convert to HTML, and return to the user's browser. Models: Holds the classes that model and wrap the data stored in our application's database. Helpers: Holds any helper classes used to assist the model, view, and controllers classes Methods: link_to → creates a hyperlink to an action example: <%= link_to "Hello", say_hello_path %> Marshaling Objects: Take an object and convert it into a stream of bytes that can be stored outside the app. rails generate migration add_columnname_to_tablename columnname:datatype example: rails generate migration add_password_to_users password:string Problem Solve Take-note Get URL parameter path = request.fullpath path_search = URI.parse(path) parse_url = CGI.parse(path_search.query) array_facility_choose = parse_url['search[facilities][]']#params['search']['facilities'] name_facility = Array.new # content all name of facility choose search[prefecture]=&search[departments][]=3&search[facilities][]=2 To create a model that references another, use the rails model generator: $ rails g model wheel car:references class Wheel < ActiveRecord::Base belongs_to :car end class CreateWheels < ActiveRecord::Migration
  • 2. def self.up create_table :wheels do |t| t.references :car t.timestamps end end ActiveRecord Products.connection.execute('UPDATE `products` SET `price`=`free` WHERE 1') If the helpers not enough Rename column script/generate migration rename_my_column_by_hand Then edit the file it creates: class RenameMyColumnByHand < ActiveRecord::Migration def self.up rename_column :my_table, :old_name, :new_name end def self.down rename_column :my_table, :new_name, :old_name end end It executes SQL like: ALTER TABLE my_table CHANGE old_name new_name BIGINT; Change type of column class AddColumnToTable < ActiveRecord::Migration def change add_column :table, :column, :type end end Rails g migration changetypecolumn Add column rails generate migration add_password_to_users password:string rails generate migration add_columnname_to_tablename