By: Jay Hayes https://iamvery.com https://twitter.com/iamvery
You're about to build a chat room. Cool!
-
Make the
Topicscomponent display topics dynamically by injecting data as a property.
| defmodule PantsWeb.ChangesetView do | |
| use PantsWeb, :view | |
| @doc """ | |
| Traverses and translates changeset errors. | |
| See `Ecto.Changeset.traverse_errors/2` and | |
| `PantsWeb.ErrorHelpers.translate_error/1` for more details. | |
| """ | |
| def translate_errors(changeset) do |
| diff --git a/lib/pants_web/endpoint.ex b/lib/pants_web/endpoint.ex | |
| index c24852a..a8ae2cf 100644 | |
| --- a/lib/pants_web/endpoint.ex | |
| +++ b/lib/pants_web/endpoint.ex | |
| @@ -45,7 +45,19 @@ defmodule PantsWeb.Endpoint do | |
| signing_salt: "HqMY6W5G" | |
| ) | |
| - plug(PantsWeb.Router) | |
| + def version(conn, []) do |
| quote do: {:a, :b, :c} | |
| value = {:a, :b, :c} | |
| Macro.escape(value) | |
| quote do: value | |
| value = {:a, :b, :c} | |
| quote do: unquote(value) |
| { | |
| "name": "frontier", | |
| "version": "0.1.0", | |
| "private": true, | |
| "devDependencies": { | |
| "jest-expo": "~19.0.0", | |
| "react-dom": "16.0.0-alpha.12", | |
| "react-native-dotenv": "^0.1.0", | |
| "react-native-scripts": "1.1.0", | |
| "react-test-renderer": "16.0.0-alpha.12" |
By: Jay Hayes https://iamvery.com https://twitter.com/iamvery
You're about to build a chat room. Cool!
Make the Topics component display topics dynamically by injecting data as a property.
| // Relevant links: | |
| // - This pen https://goo.gl/98wWXr | |
| // - Complete example https://goo.gl/aYazLi (DON'T CHEAT! xD) | |
| // - Server source code https://goo.gl/g2dcdC (not needed, but you might be interested) | |
| let Topics = ({topics, setTopic}) => | |
| <div> | |
| <h4>Click on a topic...</h4> | |
| <ul> | |
| {topics.map(topic => <li><a href="#" onClick={() => setTopic(topic)}>{topic}</a></li>)} |
| RSpec.describe 'pairing elements of an array' do | |
| def find_pairs(arr) | |
| [] # ??? | |
| end | |
| it 'returns a pair iterating through the array one element at a time' do | |
| a = [1,2,3,4] | |
| pairs = find_pairs(a) | |
| expect(pairs).to eq([[1,2],[2,3],[3,4]]) | |
| end |
| <%- if controller_name != 'sessions' %> | |
| <%= link_to "Log in", new_session_path(resource_name) %><br /> | |
| <% end -%> | |
| <%- if devise_mapping.registerable? && controller_name != 'registrations' %> | |
| <%= link_to "Sign up", new_registration_path(resource_name) %><br /> | |
| <% end -%> | |
| <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> | |
| <%= link_to "Forgot your password?", new_password_path(resource_name) %><br /> |
| <h2>Log in</h2> | |
| <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> | |
| <div class="field"> | |
| <%= f.label :email %><br /> | |
| <%= f.email_field :email, autofocus: true %> | |
| </div> | |
| <div class="field"> | |
| <%= f.label :password %><br /> |