In this challenge, you will meet your old friend Active Record, which is Rails' ORM.
Build a Rails todolist application. Your todo-app should have 7 entry points in the routing:
GET '/tasks'
: get all your tasks.
class Dog | |
def walk(location, distance) | |
@location = location | |
@distance = distance | |
end | |
end | |
tilly = Dog.new | |
tilly.walk("brighton", 5) | |
p tilly |
public class Animal { | |
public Animal(String name) { | |
name = name; | |
} | |
public static void main(String[] args) { | |
Animal bear = new Animal("bear"); | |
System.out.println(bear); | |
} | |
} |
public class Dog { | |
public static int walks = 0; | |
public String location = null; | |
public Dog(String name, int age) { | |
name = name; | |
age = age; | |
} | |
public void bark() { |
import java.util.Date; | |
public class Car { | |
private String brand; | |
private String colour; | |
private int wheels; | |
private Date date = new Date(); | |
public Car(String brand, String colour) { | |
this.brand = brand; |
Git is kind of like Google Docs.
It's the way developers save their code. It's also the way we can push our code to the cloud (GitHub) and collaborate with other developers. This whole process is called version control.
Google Docs has it's own kind of version control. In Git it's similar but more developer friendly because everything happens on the command line.
Now that you have created your first Rails App and started looking inside the application directory we know some of you hunger for the details of all the folders and files generated. So here is a quick rundown of what in each directory. Take your time and explore away.
app
is where you'll put the majority of your application code. You'll be spending alot of time in here. Rails is very opinionated software so it place a lot of emphasis on keeping code organized, so the app directory has a number of sub-directories:
assets
contains sub-directories where you'll store your application's images, JavaScript files, and stylesheets (CSS)
channels
is where you put Ruby classes designed to handle real-time features using Action Cable
<h1>Link shortener</h1> | |
<%= form_for(Link.new, url: link_path) do |f| %> | |
<%= f.text_field :original_url %> | |
<%= f.submit "Create short link" %> | |
<% end %> |
before_action :configure_permitted_parameters, if: :devise_controller? | |
protected | |
def configure_permitted_parameters | |
devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :dob]) | |
end |