- The document discusses various rendering methods and layouts in Rails, including default rendering, using the 'render' method, options for render like :content_type and :layout, and using redirect_to versus render. It also covers finding and structuring layouts, asset tag helpers, and head-only responses.
Improve speed & performance of informix 11.xx part 1am_prasanna
A presentation deck, that takes a deep dive on configuration parameters of IBM Informix database server, enhancing the Performance and thus boosting the speed with which, one can work with Informix DB. The presentation is split into two parts, i.e Part 1 and 2
This is the slides I used when I shared my humble insight on Django to the students in University of Taipei in 2016. Please feel free to correct me if there is anything wrong.
Improve speed & performance of informix 11.xx part 1am_prasanna
A presentation deck, that takes a deep dive on configuration parameters of IBM Informix database server, enhancing the Performance and thus boosting the speed with which, one can work with Informix DB. The presentation is split into two parts, i.e Part 1 and 2
This is the slides I used when I shared my humble insight on Django to the students in University of Taipei in 2016. Please feel free to correct me if there is anything wrong.
How to do Test Driven Development to write Chef cookbooks?
This slide-deck explains how to use TDD and tools of the trade, to develop cookbooks, Unit Tests and Integration Tests.
Source code is available on GitHub: https://github.com/siso/cheftdd-cookbook
Champaign-Urbana Javascript Meetup Talk (Jan 2020)Susan Potter
Using Purescript (which transpiles to Javascript), we look at how you can build an API over HTTP by describing our endpoints using expressive types that can be deployed as a simple Node process. With this approach we try to focus our development efforts on our business domain and logic as opposed to the plumbing.
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 our CodeMash 2013 Precompiler session, "Web Development with Python and Django", including a breezy introduction to the Python programming language and the Django web framework. The example code repository is available at https://github.com/finiteloopsoftware/django-precompiler/
Model-Driven Software Development - Strategies for Design & Implementation of...Eelco Visser
Lecture 5 of course on Model-Driven Software Development about Strategies for Design & Implementation of Domain-Specific Languages, discussing design and implementation of WebDSL
»Spring 3« ist da. Vieles ist geblieben, manches verschwunden, manches neu. Spring 3 verspricht eine verbesserte und dynamischere Konfiguration, einen leistungsfähigen und mächtigen REST-Support und viele kleine Verbesserungen. Parallel zu dem Spring 3-Release wurden auch andere Tools und Projekte aktualisiert, auf die wir ebenfalls einen Blick werfen wollen:
* Wichtige Änderungen
* Java Configuration
* Spring Expression Language
* Spring MVC und Rest
* Embedded Database
* SpringSource Toolsuite
* Spring Roo
* Grails
Since late 2009 there is Spring 3 published. Some things are new, something keep and something was removed.
Thos talk discuss the changes of the 3rd edition of Spring and introduce Spring Roo, Grails and the SpringSource Toolsuite.
How to do Test Driven Development to write Chef cookbooks?
This slide-deck explains how to use TDD and tools of the trade, to develop cookbooks, Unit Tests and Integration Tests.
Source code is available on GitHub: https://github.com/siso/cheftdd-cookbook
Champaign-Urbana Javascript Meetup Talk (Jan 2020)Susan Potter
Using Purescript (which transpiles to Javascript), we look at how you can build an API over HTTP by describing our endpoints using expressive types that can be deployed as a simple Node process. With this approach we try to focus our development efforts on our business domain and logic as opposed to the plumbing.
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 our CodeMash 2013 Precompiler session, "Web Development with Python and Django", including a breezy introduction to the Python programming language and the Django web framework. The example code repository is available at https://github.com/finiteloopsoftware/django-precompiler/
Model-Driven Software Development - Strategies for Design & Implementation of...Eelco Visser
Lecture 5 of course on Model-Driven Software Development about Strategies for Design & Implementation of Domain-Specific Languages, discussing design and implementation of WebDSL
»Spring 3« ist da. Vieles ist geblieben, manches verschwunden, manches neu. Spring 3 verspricht eine verbesserte und dynamischere Konfiguration, einen leistungsfähigen und mächtigen REST-Support und viele kleine Verbesserungen. Parallel zu dem Spring 3-Release wurden auch andere Tools und Projekte aktualisiert, auf die wir ebenfalls einen Blick werfen wollen:
* Wichtige Änderungen
* Java Configuration
* Spring Expression Language
* Spring MVC und Rest
* Embedded Database
* SpringSource Toolsuite
* Spring Roo
* Grails
Since late 2009 there is Spring 3 published. Some things are new, something keep and something was removed.
Thos talk discuss the changes of the 3rd edition of Spring and introduce Spring Roo, Grails and the SpringSource Toolsuite.
CouchDB for Web Applications - Erlang Factory London 2009Jason Davies
CouchDB is built "of the Web" and it's very exciting to convert the immense
power that CouchDB provides into a usable, real-world Web application. In this
talk I cover case studies of real-world applications that use CouchDB,
including some that can be served from CouchDB itself, and how CouchDB can
shape your Web applications to be highly scalable and flexible by embracing
HTTP philosophies, JavaScript and schemaless documents.
APIs REST Usables con Hypermedia por Javier Ramirez, para codemotionjavier ramirez
Con la adopción de REST, la proliferación de smartphones y tablets y el revival del JavaScript, exponer nuestra aplicación como un servicio es más importante que nunca.
Frameworks como Rails hacen muy fácil la creación de un API (más o menos) REST, pero en muchas ocasiones estas APIs se diseñan sin pensar realmente en los desarrolladores que las va a usar.
En esta charla habo sobre algunos de los puntos que pueden hacer tu API REST más amigable para desarrolladores, cubriendo áreas como el autodescubrimiento, autenticación, cabeceras, formatos, versionado, parámetros, documentación y herramientas.
Aunque comparte tema (y algunas slides) con la charla de APIs usables que preparé para el grupo de Usuarios de Ruby en Londres, gran parte del material es inédito.
Similar to Layouts and Rendering in Rails, Season 2 (20)
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.
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!
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
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
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.
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?
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.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
6. Default Rendering
/books
class BooksController < ApplicationController
end
BooksController
resources :books
config/routes.rb
<h1>Books are coming soon!</h1>
app/views/books/index.html.erb
7. Default Rendering
resources :books
config/routes.rb
$ rake routes CONTROLLER=books
books GET /books(.:format) books#index
POST /books(.:format) books#create
new_book GET /books/new(.:format) books#new
edit_book GET /books/:id/edit(.:format) books#edit
book GET /books/:id(.:format) books#show
PUT /books/:id(.:format) books#update
DELETE /books/:id(.:format) books#destroy
8. Default Rendering
class BooksController < ApplicationController
def index
@books = Book.all
end
end
• {action_name}.html.erb
C oC : app/views/books/index.html.erb
10. Using ‘Render’
Many ways to customize rendering
• Default view
: for a Rails template / a specific template / a file / inline code /
nothing
• text / JSON / XML
class BooksController < ApplicationController
def index
@books = Book.all
render “index”
render_to_string “index”
render :nothing => true
end
end
11. Using ‘Render’
Rendering an Action’s view
def update
@book = Book.find(params[:id])
if @book.update_attributes(params[:book])
redirect_to(@book)
else
render "edit"
end
as a String
end
12. Using ‘Render’
Rendering an Action’s view
def update
@book = Book.find(params[:id])
if @book.update_attributes(params[:book])
redirect_to(@book)
else
render :edit
end
as a Symbol
end
13. Using ‘Render’
Rendering an Action’s view
def update
@book = Book.find(params[:id])
if @book.update_attributes(params[:book])
redirect_to(@book)
else
render :action => "edit"
end
to render “edit” action’s view
end
14. Using ‘Render’
Rendering an Action’s Template
from Another Controller
def update
@book = Book.find(params[:id])
if @book.update_attributes(params[:book])
redirect_to(@book)
else
render "products/show"
render :template => "products/show"
end
from another controller
end
15. Using ‘Render’
Rendering an Arbitrary File
def update
@book = Book.find(params[:id])
if @book.update_attributes(params[:book])
redirect_to(@book)
else
render "/u/apps/warehouse_app/current/app/
views/products/show"
render :file => "/u/apps/warehouse_app/current/
app/views/products/show", :layout => true
end
end
24. Options
for Render
:layout option
render :layout => 'special_layout'
to tell Rails to use a specific file
as the layout for the current action
render :layout => false
25. Options
for Render
:location option
render :xml => photo, :location => photo_url(photo)
to set the HTTP Location header
27. Status Code Status Message Symbol Status Code Status Message Symbol
1xx Informational 406 Not Acceptable :not_acceptable
100 Continue :continue Proxy Authentication :proxy_authentication_req
407
101 Switching Protocols :switching_protocols Required uired
408 Request Timeout :request_timeout
102 Processing :processing
409 Conflict :conflict
2xx Success 410 Gone :gone
200 OK :ok 411 Length Required :length_required
201 Created :created
412 Precondition Failed :precondition_failed
202 Accepted :accepted
413 Request Entity Too Large :request_entity_too_large
203 Non-Authoritative :non_authoritative_inform
Information ation 414 Request-URI Too Long :request_uri_too_long
204 No Content :no_content
205 Reset Content :reset_content 415 Unsupported Media Type :unsupported_media_type
206 Partial Content :partial_content 416 Requested Range Not :requested_range_not_sati
207 Multi-Status :multi_status Satisfiable sfiable
417 Expectation Failed :expectation_failed
226 IM Used :im_used
422 Unprocessable Entity :unprocessable_entity
423 Locked :locked
3xx Redirection
300 Multiple Choices :multiple_choices 424 Failed Dependency :failed_dependency
301 Moved Permanently :moved_permanently 426 Upgrade Required :upgrade_required
302 Found :found
303 See Other :see_other
5xx Server Error
304 Not Modified :not_modified
500 Internal Server Error :internal_server_error
305 Use Proxy :use_proxy
307 Temporary Redirect :temporary_redirect 501 Not Implemented :not_implemented
4xx Client Error 502 Bad Gateway :bad_gateway
400 Bad Request :bad_request 503 Service Unavailable :service_unavailable
401 Unauthorized :unauthorized
504 Gateway Timeout :gateway_timeout
402 Payment Required :payment_required
505 HTTP Version Not :http_version_not_support
403 Forbidden :forbidden Supported ed
404 Not Found :not_found 507 Insufficient Storage :insufficient_storage
405 Method Not Allowed :method_not_allowed 510 Not Extended :not_extended
28. Finding Layouts
• Rails first looks for a file in app/views/layouts
with the same base name as the controller.
Current
Controller layout
layout
inheritance
Application layout
29. Finding Layouts
Specifying Layouts for Controllers
class ProductsController < ApplicationController
layout "inventory"
#...
end
app/views/layouts/inventory.html.erb
class ApplicationController < ActionController::Base
layout "main"
#...
end
app/views/layouts/main.html.erb
30. Finding Layouts
Choosing Layouts at Runtime
class ProductsController < ApplicationController
layout :products_layout
def show
@product = Product.find(params[:id])
end
private
def products_layout
@current_user.special? ? "special" : "products"
end
end
31. Finding Layouts
Choosing Layouts at Runtime
class ProductsController < ApplicationController
layout Proc.new { |controller|
controller.request.xhr? ? 'popup' : 'application' }
end
using inline method!
32. Finding Layouts
Conditional Layouts
class ProductsController < ApplicationController
layout "product", :only => [:index, :rss]
end
class ProductsController < ApplicationController
layout "product", :except => [:index, :rss]
end
33. Finding Layouts
Layout Inheritance (1) cascading downward
‣ application_controller.rb
class ApplicationController < ActionController::Base
layout "main"
end
‣ posts_controller.rb
class PostsController < ApplicationController
end
34. Finding Layouts
Layout Inheritance (2) cascading downward
‣ special_posts_controller.rb
class SpecialPostsController < PostsController
layout "special"
end
35. Finding Layouts
cascading downward
Layout Inheritance (3)
‣ old_posts_controller.rb
class OldPostsController < SpecialPostsController
layout false
def show
@post = Post.find(params[:id])
end
def index
@old_posts = Post.older
render :layout => "old"
end
# ...
end
36. Using Redirect_to
• redirect_to
- tell the browser to send a new request
for a different URL
• cf. render
- a view template
redirect_to photos_url
redirect_to :back
37. Using Redirect_to s : 30
2
tatu
lt s
de fau
Different Redirect Status Code
redirect_to photos_path, :status => 301
38. Using Redirect_to
Render vs Redirect_to
def index def index
@books = Book.all @books = Book.all
end end
def show def show
@book = Book.find_by_id(params[:id]) @book = Book.find_by_id(params[:id])
if @book.nil? if @book.nil?
render :action => "index" redirect_to :action => :index
end end
end end
a round trip to the browser
39. Using Redirect_to
Render vs Redirect_to
def index
@books = Book.all
end
def show
@book = Book.find_by_id(params[:id])
if @book.nil?
@books = Book.all
render "index", :alert => 'Your book was not found!'
end
end
one stop rendering
40. Head-Only
Responses
• render :nothing
• a more obvious alternative
‘head’ method
41. Head-Only
Responses
head :bad_request
HTTP/1.1 400 Bad Request
Connection: close
Date: Sun, 24 Jan 2010 12:15:53 GMT
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
X-Runtime: 0.013483
Set-Cookie: _blog_session=...snip...; path=/; HttpOnly
Cache-Control: no-cache
42. Head-Only
Responses
head :created, :location => photo_path(@photo)
HTTP/1.1 201 Created
Connection: close
Date: Sun, 24 Jan 2010 12:16:44 GMT
Transfer-Encoding: chunked
Location: /photos/1
Content-Type: text/html; charset=utf-8
X-Runtime: 0.083496
Set-Cookie: _blog_session=...snip...; path=/; HttpOnly
Cache-Control: no-cache
43. Structuring
Layouts
Three tools for knitting fragmented outputs
• Asset tags ( for asset links )
• yield and content_for ( for layouts )
• Partials ( for refactoring )
44. Structuring
Layouts
Asset Tag Helpers
• auto_discovery_link_tag
• javascript_include_tag in <head> section
• stylesheet_link_tag
• image_tag
• video_tag in <body> section
• audio_tag
45. Structuring
Layouts
Asset Tag Helpers
auto_discovery_link_tag RSS or ATOM feeds
<%= auto_discovery_link_tag(:rss, {:action => "feed"},
{:title => "RSS Feed"}) %>
57. Partial
• breaking the render process into more
chunks
• moving the code chunk to its own file
• _partial.html.erb vs partial.html.erb
• to simplify views
• partial layout
58. Partial
<%= render "menu" %>
<%= render "shared/menu" %>
<%= render "shared/ad_banner" %>
<h1>Products</h1>
<p>Here are a few of our fine products:</p>
...
<%= render "shared/footer" %>
<%= render :partial => "link_area", :layout => "graybar"
60. A Partial variable
• a local variable with the same name as the
partial
• pass an object in to this local variable
<%= render :partial => "customer", :object => @new_customer %>
<%= render @customer %>
61. Rendering Collections
Rails determines the name of the partial to use by looking at
the model name in the collection. In fact, you can even create a
heterogeneous collection and render it this way
<h1>Products</h1>
<%= render :partial => "product",
:collection => @products %>
index.html.erb
<p>Product Name: <%= product.name %></p>
_product.html.erb
62. Rendering Collections
Rails determines the name of the partial to use by looking at
the model name in the collection. In fact, you can even create a
heterogeneous collection and render it this way
ra
ils
3.
<h1>Products</h1> 0
<%= render(@products) || ‘there are no products
available.’ %>
index.html.erb
<p>Product Name: <%= product.name %></p>
_product.html.erb