enable_starttls_auto: true
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: '***************',
user_name: '***************',
password: '*******************',
authentication: 'plain',
enable_starttls_auto: true
}
create
создаёт обьект из переданных параметров и сразу сохраняет его, так что добавление потом @comment.user = current_user
create
используйте build
и сохраняйте руками@comment.save
@comment = @post.comments.build(comment_params)
@comment.user = current_user
@comment.save
@feed_items = @category.posts.where(status: params[то что придёт от юзера]).paginate(page: params[:page])
ActionController::Live
для этого, чем трогать сервер каждые 5 сек. Когда запись добавится, через ActionController::Live
сможете дёрнуть клиента и обновить данные. Погуглите в эту сторону. <%= form_for([@post, @new_comment]) do |f| %>
[@post, @new_comment]
рельсы создают своё url что то типа /posts/{post_id}/comments/{comment_id}
application.html.erb
в саммый конец вот это<%= debug(params) if Rails.env.development? %>
@parent = Comment.find(params[:comment][:parent_id])
parent_id
в hiden field@parent = Comment.find(params[:parent_id])
<% @comments.each do |comment| %> #проходимся по комментам
<%= comment.user.user_name%> # кто написал коммент
<% if comment.has_children? %>
#сделать линк по которому ajax будут забиратся коменты для этой ветки?
#или делать еще 1 do block и проходить по дочерним комментам.
<% else %>
<% end %>
Comment
как я понимаю для этого есть метод has_children?
def tag_list text
text.split(" ")
end
f.collection_select
.<%= f.label :tag_ids, "Теги", :class => 'css class' %>
<%= f.collection_select(:tag_ids Tag.all, :id, :name, {}, :class => 'css class') %>
class CreatePostVotes < ActiveRecord::Migration
def change
create_table :post_votes do |t|
t.string :user_ip
t.integer :post_id
t.integer :value
t.timestamps
end
add_index :post_votes, [:user_ip, :post_id], :unique => true
add_index :post_votes, :user_ip
add_index :post_votes, :post_id
end
end
#validations
validates :post_id, uniqueness: {scope: :user_ip}
validates :value, inclusion: { in: [1, -1], message: "%{value} is not a valid vote" }
app/assets
— для файлов которые принадлежат или созданы самой аппликации. lib/assets
— для своих библиотек, которые вы сами написали и принадлежат вам.vendor/assets
— для библиотек от сторонних разработчиков.app/assets
в этом ничего страшного нет, просто не красиво и руки не доходят переставить всё на свои места — лень…# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'bootstrap-sass'
gem 'chosen-rails'
gem 'angularjs-rails'
gem 'markitup-rails'
gem 'font-awesome-rails'
end
gem 'chosen-rails'
gem 'markitup-rails'
config/application
config.assets.paths << "/home/username/Dropbox/jsLibs"