- The document discusses building a blog application with Rails that allows users to add comments to posts
- It covers generating models for posts and comments, associating the models, adding routes and controllers, and rendering comments and a comment form partial to clean up the views
- The key steps are generating the post and comment models, associating them with a belongs_to/has_many relationship, building out the comments controller and views to display existing comments and render a form for adding new comments
Dans cette session vous apprendrez tout sur Ruby. Le langage, les frameworks, la communauté, mais surtout un esprit. Passé le teaser, Nicolas Ledez vous présentera comment Ruby peut vous apporter tous les jours une méthodologie dans votre travail, et des outils pour réaliser un prototype rapidement. Quel que soit votre langage d'origine, Ruby complète parfaitement votre boite à outils de développeur/administrateur système.
Slides from @apotonick's talk during 14th #pivorak Lviv Ruby Meetup, Ukraine.
Nick is a Trailblazer creator and it gives developers structure and architectural guidance and finally answers the question of "Where do I put this kind of code?" in Rails.
What's Trailblazer?
“To a better code structure with more abstraction layers. Trailblazer introduces desperately needed new objects into web architectures like Rails. Form objects, operations, policies, view models, and more, help engineering teams to step-wise introduce the Trailblazer architecture into messy Rails apps.”
Dans cette session vous apprendrez tout sur Ruby. Le langage, les frameworks, la communauté, mais surtout un esprit. Passé le teaser, Nicolas Ledez vous présentera comment Ruby peut vous apporter tous les jours une méthodologie dans votre travail, et des outils pour réaliser un prototype rapidement. Quel que soit votre langage d'origine, Ruby complète parfaitement votre boite à outils de développeur/administrateur système.
Slides from @apotonick's talk during 14th #pivorak Lviv Ruby Meetup, Ukraine.
Nick is a Trailblazer creator and it gives developers structure and architectural guidance and finally answers the question of "Where do I put this kind of code?" in Rails.
What's Trailblazer?
“To a better code structure with more abstraction layers. Trailblazer introduces desperately needed new objects into web architectures like Rails. Form objects, operations, policies, view models, and more, help engineering teams to step-wise introduce the Trailblazer architecture into messy Rails apps.”
Normal Labour/ Stages of Labour/ Mechanism of LabourWasim Ak
Normal labor is also termed spontaneous labor, defined as the natural physiological process through which the fetus, placenta, and membranes are expelled from the uterus through the birth canal at term (37 to 42 weeks
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
4. Adding
a Second Model
Model Class Database Table
Comment Active
Record
comments
object record
attributes fields
ROR Lab.
5. Generating
a Model
$ rails generate model Comment
commenter:string
body:text
post:references
generate scaffold
generate model
generate controller
generate migration
ROR Lab.
6. Generating
a Model
$ rails generate model Comment
commenter:string
body:text
Migration file
Model Class : db/migrate/xxxx_create_comment.rb
: app/models/comment.rb
Comment Comments
belongs_to :post post_id :integer
post:references
ROR Lab.
7. Generating
a Model
class Comment < ActiveRecord::Base
belongs_to :post
end
Model class file
@comment.post
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.string :commenter
t.text :body
t.references :post
t.timestamps Migration file
end
add_index :comments, :post_id
end
end
$ rake db:migrate
ROR Lab.
8. Associating
Models
Parent Model Relation Child Model
has_many
Post Comment
belongs_to
app/models/post.rb app/models/comment.rb
ROR Lab.
36. Deleting
Comments
DELETE /posts/:post_id/comments/:id
$ rake routes
post_comments GET /posts/:post_id/comments(.:format) comments#index
POST /posts/:post_id/comments(.:format) comments#create
new_post_comment GET /posts/:post_id/comments/new(.:format) comments#new
edit_post_comment GET /posts/:post_id/comments/:id/edit(.:format) comments#edit
post_comment GET /posts/:post_id/comments/:id(.:format) comments#show
PUT /posts/:post_id/comments/:id(.:format) comments#update
DELETE /posts/:post_id/comments/:id(.:format) comments#destroy
posts GET /posts(.:format) posts#index
POST /posts(.:format) posts#create
new_post GET /posts/new(.:format) posts#new
edit_post GET /posts/:id/edit(.:format) posts#edit
post GET /posts/:id(.:format) posts#show
PUT /posts/:id(.:format) posts#update
DELETE /posts/:id(.:format) posts#destroy
ROR Lab.
37. Deleting
Comments
DELETE /posts/:post_id/comments/:id
$ rake routes
post_comments GET /posts/:post_id/comments(.:format) comments#index
POST /posts/:post_id/comments(.:format) comments#create
new_post_comment GET /posts/:post_id/comments/new(.:format) comments#new
edit_post_comment GET /posts/:post_id/comments/:id/edit(.:format) comments#edit
post_comment GET /posts/:post_id/comments/:id(.:format) comments#show
PUT /posts/:post_id/comments/:id(.:format) comments#update
DELETE /posts/:post_id/comments/:id(.:format) comments#destroy
posts GET /posts(.:format) posts#index
POST /posts(.:format) posts#create
new_post GET /posts/new(.:format) posts#new
edit_post GET /posts/:id/edit(.:format) posts#edit
post GET /posts/:id(.:format) posts#show
PUT /posts/:id(.:format) posts#update
DELETE /posts/:id(.:format) posts#destroy
ROR Lab.
38. Deleting
Comments
class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create(params[:comment])
redirect_to post_path(@post)
end
def destroy
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
@comment.destroy
redirect_to post_path(@post)
end
end
ROR Lab.
39. Deleting
Comments
class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create(params[:comment])
redirect_to post_path(@post)
end
def destroy
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
@comment.destroy
redirect_to post_path(@post)
end
end
ROR Lab.
42. Security
A very simple HTTP authentication system
class PostsController < ApplicationController
http_basic_authenticate_with
:name => "dhh",
:password => "secret",
:except => [:index, :show]
# GET /posts
# GET /posts.json
def index
@posts = Post.all
respond_to do |format|
ROR Lab.
43. Security
A very simple HTTP authentication system
class PostsController < ApplicationController
http_basic_authenticate_with
:name => "dhh",
:password => "secret",
:except => [:index, :show]
# GET /posts
# GET /posts.json
def index
@posts = Post.all
respond_to do |format|
ROR Lab.
44. Security
A very simple HTTP authentication system
class CommentsController < ApplicationController
http_basic_authenticate_with
:name => "dhh",
:password => "secret",
:only => :destroy
def create
@post = Post.find(params[:post_id])
ROR Lab.
45. Security
A very simple HTTP authentication system
class CommentsController < ApplicationController
http_basic_authenticate_with
:name => "dhh",
:password => "secret",
:only => :destroy
def create
@post = Post.find(params[:post_id])
ROR Lab.