micropost.user Возвращает объект User связанный с микросообщением. user.microposts Возвращает массив микросообщений пользователя. user.microposts.create(arg) Создает микросообщение (user_id = user.id). user.microposts.create!(arg) Создает микросообщение (с исключением в случае неудачи). user.microposts.build(arg) Возвращает объект new Micropost (user_id = user.id).
Micropost.where(“user_id = ?”, id)
<% user = micropost.user rescue User.find(micropost.user_id) %> <% if current_user?(user) %>
(сложное) Добавить JavaScript отображение к Home странице для обратного отсчета 140 знаков.
Добавить вложенные маршруты так, чтобы по адресу /users/1/microposts показывались все микросообщения пользователя 1. (Вам также необходимо будет добавить в контроллер Microposts действие index и соответствующее представление.)
coffee
/*Top level list items*/ - which commment
link to admin
custom validation message
class=“<%= cycle(‘list_line_odd’, ‘list_line_even’) %>”
• Add the ability to delete individual line items from the cart. This will require buttons on each line, and such buttons will need to be linked to the destroy() action in the LineItemsController.
global variable in view page
Add a button next to each item in the cart. When clicked, it should invoke an action to decrement the quantity of the item, deleting it from the cart when the quantity reaches zero. Get it working without using Ajax first, and then add the Ajax goodness.
legend and fieldset
select promt
Playtime • Add a ship_date column to the orders table, and send a notification when this value is updated by the OrdersController. • Update the application to send an email to the system administrator, namely, yourself, when there is an application failure such as the one we handled in Section 10.2, Iteration E2: Handling Errors, on page 119.
has_secure_password
gem ‘redcloth’
sublocations in locations
Add a locale column to the products database, and adjust the index view to select only the products that match the locale. Adjust the products view so that you can view, enter, and alter this new column. Enter a few products in each locale, and test the resulting application. • Determine the current exchange rate between U.S. dollars and euros, and localize the currency display to display euros when ES_es is selected. • Translate the Order::PAYMENT_TYPES shown in the drop-down. You will need to keep the option value (which is sent to the server) the same. Only change what is displayed.
offset(), joins(), group(), lock(), readonly()
scope
And default_url_options also does pretty much what it says, in that it provides a hash of URL options that are to be considered as present whenever they aren’t otherwise provided. In this case, we are providing a value for the :locale parameter. This is needed when a view on a page that does not have the locale specified attempts to construct a link to a page that does. We will see that in use soon.
send_file and send_data
:placeholder
mysql --max_allowed_packet=100M -u root -p database < dump.sql
Also, change the my.cnf or my.ini file under the mysqld section and set max_allowed_packet=100M or you could run these commands in a MySQL console connected to that same server:
set global net_buffer_length=1000000; set global max_allowed_packet=1000000000;