LHL Ruby on Rails notes

编程入门 行业动态 更新时间:2024-10-09 14:22:16

LHL <a href=https://www.elefans.com/category/jswz/34/1755139.html style=Ruby on Rails notes"/>

LHL Ruby on Rails notes

Ruby
The methods need to know for Arrays in Ruby all rhyme
select is ‘filter’ in javascript
collect is ‘map’ in javascript
inject is ‘reduce’ in javascript
detect is ‘find’ in javascript
reject is not in Javascript

Ruby on Rails

* MVC Frameworks (Model- View - Controller)* Ruby on Rails * ASP.NET MVC (C#)* Django ( Python)* Codeigniter (PHP)Route Handler style (Middleware)* Legacy PHP* Express* Sinatra (Ruby)Hanami (Ruby)Three buckets of code: * Providing an interface: view* Performing Business Logic: controler* Example: Tinyapp `POST` `/urls`* Redirect if not logged in * If logged in, get user from session* Data integrity check (400- clinet error)* Save url to database* Return the created url(201) / redirect to `GET` `/urls`* Querying and Modifying Data Stores: ModelModel: REACT
MVC Framework expects you to put 
Model stuff in Model classes, 
Controller stuff in Controller class, 
View stuff in View classesRails is great at 20% of web server techniques used in 80% of the situation.
very opinionated:
* You are trying to make an HTTP server
* Your app logic can be sorted into resources, onto which you will perform BREADoperation 
* It's better to have a buch of built in functionality
* 
gem install rails
oop - Object-Oriented Programig
rails console - this will create a repl in cmd you could do CRUD
rails dbconsole - it will use SQLITE for the database

2.7.2 Shallow Nesting
One way to avoid deep nesting is to generate the collection actions scoped under the parent, so as to get a sense of the hierarchy, but to not nest the member actions. In other words, to only build routes with the minimal amount of information to uniquely identify the resource, like this:

resources :articles doresources :comments, only: [:index, :new, :create]
end
resources :comments, only: [:show, :edit, :update, :destroy]

This idea strikes a balance between descriptive routes and deep nesting. There exists shorthand syntax to achieve just that, via the :shallow option:

resources :articles doresources :comments, shallow: true
end

更多推荐

LHL Ruby on Rails notes

本文发布于:2024-02-06 09:09:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1748119.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Ruby   LHL   notes   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!