This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show | |
@forum = Forum::Forum.find_by_id(params[:id]) | |
if @forum.hidden && !(user_in?([:admins, :masters]) || user_permitted?(:show_hidden)) | |
url = case @forum.parent_id | |
when 0 then forum_index_path | |
else forum_path(@forum.parent) | |
end | |
redirect_to url | |
end | |
rendering the forum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url = "http://napodiume.ru/profile/"+model[:id] | |
puts "Соединяемся с профилем №#{model[:id]}" | |
doc = Nokogiri::HTML(open(url)) | |
name = (doc.at_css("h1").text.split "|")[0] | |
@model = Model.new | |
@model.name = name.strip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From params: | |
#<ActionDispatch::Http::UploadedFile:0x00000003aa01d8 @original_filename="58.png", | |
@content_type="image/png", | |
@headers="Content-Disposition: form-data; name=\"bug[screen]\"; filename=\"58.png\"\r\nContent-Type: image/png\r\n", | |
@tempfile=#<File:/tmp/RackMultipart20120514-17845-2755c4>> | |
-------------------------------------------------------- | |
In the model: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#--Model | |
class Forum::Forum < ActiveRecord::Base | |
#has a field called 'name' | |
#--Form (in the view) | |
<%= form_for @forum do |f| %> | |
<%= f.label :name %>: <%=f.text_field :name %><br /> | |
<%= f.submit "Send" %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#The Error | |
ActionView::Template::Error (Infinity): | |
<div class="forum_right_links"> | |
<% chars = (@topic.forum.tech == 1) ? :owned_real : :active %> | |
<%= link_to t("forum.links.moderate"), "", :remote => false if user_permitted? :moderate %> | |
</div> | |
<%= will_paginate(@posts) %> | |
<div class="posts_wrap"> | |
<% @posts.each do |post| %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Forum model | |
has_many :topics | |
#Topic model | |
belongs_to :forum | |
#forums#show action | |
def show | |
@forum = Forum::Forum.find_by_id(params[:id]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#show.html.erb | |
<table class="forum_list" cellpadding="0" cellspacing="0"> | |
<tr class="forum_th"> | |
<th colspan="2"><%= t "forum.lines.topics" %></th> | |
<th class="forum_posts"><%= t "forum.lines.posts" %></th> | |
<th class="forum_last_post"><%= t "forum.lines.last_post" %></th> | |
<% if user_in?([:admins, :masters]) || user_permitted?(:moderate) %> | |
<th class="forum_admin"></th> | |
<th class="forum_admin"></th> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resources :messages, :except => ["index"] do | |
collection do | |
get "/inbox", :to => "messages#inbox" | |
get "/outbox", :to => "messages#outbox" | |
get "/notify", :to => "messages#notify" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//View | |
<%= link_to "Send data", data_request_path, :class => "data_request" %> | |
//Coffee | |
$('.data_request').click -> | |
ref = data_prepare() | |
$.post { | |
$(this).attr "href", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= f.fields_for :roles do |r| %> | |
<tr class="form_line"> | |
<td class="form_head"> | |
<%= r.char.name %> | |
</td> | |
<td class="char_role_td"> | |
</td> | |
</tr> | |
<% end %> |