天道酬勤,学无止境

ruby-on-rails-3

无法在 Rails 邮件视图中生成删除链接(can't generate delete link in rails mailing view)

问题 在我看来,我有 2 个链接:一个用于编辑,效果很好,另一个用于销毁操作。 方法看起来像: def create_ticket(ticket) @ticket = ticket @edit = edit_ticket_url(@ticket, :host => "localhost:3000", :guest_password => @ticket.guest_password) @destroy = ticket_url(@ticket, :host => "localhost:3000", :guest_password => @ticket.guest_password) mail(:to => @ticket.email, :subject => @ticket.subject) 结尾 在视图模板中: <%= link_to "Edit Ticket", @edit %> <%= link_to "Delete Ticket", @destroy, :method => :delete %> 最后一个只是获取路径而不是销毁项目。 如何解决这个问题? 回答1 我认为,原因不起作用,是因为 :method => :delete 是用 javascript 处理的,并且由于从电子邮件中单击了链接,因此不会触发 javascript。 我试图解决这个问题的方法是将一个参数传递给

2021-09-25 18:33:43    分类:技术分享    ruby-on-rails   ruby   ruby-on-rails-3   actionmailer

带有 Rails 3.2.8 的 Paperclip 和 Ajax 问题(Trouble with Paperclip and Ajax with Rails 3.2.8)

问题 我正在用 rails 3.2.8 编写一个 100% ajax 应用程序 一切都很顺利,直到我尝试将员工的照片上传到员工管理模块。 这是我的代码的一部分: 在控制器: class EmpleadosController < ApplicationController respond_to :js before_filter :require_user def index @empleados = Empleado.paginate( page: params[ :page ], joins: [:user,:contacto], select: 'empleados.id as id, empleados.user_id, empleados.contratado_el, empleados.despedido_el, empleados.nss, empleados.sueldo_base_semanal, empleados.comentarios, empleados.foto_file_name, empleados.foto_content_type, empleados.foto_file_size, empleados.foto_updated_at, users.username as username, contactos.salutacion_id as

2021-09-25 18:05:10    分类:技术分享    ruby-on-rails-3   paperclip

Rails 3 array - add items with category then list items in category

As part of my Rails 3 app, I want the User to be able to click on links on other profiles/pages and have the string value of the link be added to an array belonging to that User's profile. Specifically, what I am looking to do is populate a list of :todos for each profile depending on which todo they click. The idea is that each todo will fall within one of two categories: inside and outside. So clicking the links will push the value of the todo to either inside or outside. Then the User's profile will display a list of :todos inside and outside, and count the total of todos for that User's

2021-09-25 04:37:44    分类:问答    arrays   ruby-on-rails-3

Trouble with Paperclip and Ajax with Rails 3.2.8

I am writting an application 100% ajax with rails 3.2.8 Everything was going great until I tried to upload photos of the employees to the employee management module. This is part of my code: At the Controller: class EmpleadosController < ApplicationController respond_to :js before_filter :require_user def index @empleados = Empleado.paginate( page: params[ :page ], joins: [:user,:contacto], select: 'empleados.id as id, empleados.user_id, empleados.contratado_el, empleados.despedido_el, empleados.nss, empleados.sueldo_base_semanal, empleados.comentarios, empleados.foto_file_name, empleados.foto

2021-09-25 04:06:18    分类:问答    ruby-on-rails-3   paperclip

关于布尔值的 Rails 3 和 SQLite 通信(Rails 3 and SQLite communications concerning boolians)

问题 我使用 Rails 3.2.8 和 SQLite 1.3.6 我在更改数据库中的布尔变量时遇到了麻烦 SQLite 将“t”和“f”翻译为真假 此函数不会更新:approved属性(默认为 false) def activate @user = User.find(params[:id]) if @user.update_attribute(:approved, 't') redirect_to "/" #this is the return i get so the update returns true else render "/users?approved=false" end end 但是更改像@user.update_attribute(:email,'root@email.org')这样的字符串将更新电子邮件 我该如何解决这个问题我需要某种sqlite适配器吗? 我已经安装了activerecord-jdbcsqlite3-adapter并且它搞砸了我的应用程序,因为我太草率并且没有注意到它已被弃用:P 我发现这个线程:Rails 3 SQLite3 Boolean false 但我不明白我需要做什么才能使 Rails 和 SQLite 正确通信,因为我是 Rails 的新手:) 我还认为值得一提的是,我在 Windows 7 x64 上运行它 更新 显然

2021-09-25 00:11:19    分类:技术分享    ruby-on-rails-3   sqlite   boolean   windows-7-x64

can't generate delete link in rails mailing view

In my view I have 2 links: one for edit, that works great, and one for destroy action. metod looks like: def create_ticket(ticket) @ticket = ticket @edit = edit_ticket_url(@ticket, :host => "localhost:3000", :guest_password => @ticket.guest_password) @destroy = ticket_url(@ticket, :host => "localhost:3000", :guest_password => @ticket.guest_password) mail(:to => @ticket.email, :subject => @ticket.subject) end in view template: <%= link_to "Edit Ticket", @edit %> <%= link_to "Delete Ticket", @destroy, :method => :delete %> the last one simply getting path instead of destroying item. How to solve

2021-09-25 00:09:38    分类:问答    ruby-on-rails   ruby   ruby-on-rails-3   actionmailer

Rails 3: Trying to extend Action Mailer with a module

Trying to rewrite an old alias_method_chain to add a filter on outgoing emails, and it isn't working. I'm pretty sure I've leaving something out/missing something, but I don't know what. This file is in /lib/outgoing_mail_filter.rb, which is loaded with config/initializers/required.rb Here's the old code that worked under Rails 2: class ActionMailer::Base def deliver_with_recipient_filter!(mail = @mail) unless 'production' == Rails.env mail.to = mail.to.to_a.delete_if do |to| !(to.ends_with?('some_domain.com')) end end unless mail.to.blank? deliver_without_recipient_filter!(mail) end end alias

2021-09-24 16:32:39    分类:问答    ruby-on-rails-3   module   actionmailer

rails 3- Having Action in Controller Without View

I'm a complete Rails newbie and I have a Rails Question about controllers and actions. In my controller, I have an action named vote. The code is as follows. def vote @item = Item.find(params[:id]) @item.increment(:votes) @item.save render :action => show end I have a button on a "show" view that activates this action as follows <%= button_to "Vote", :action => "vote", :id => @item.id, %> My issue is that when the button is pressed, I don't want the application to try going to /items/:id/vote. I just want the code executed, then return back to the show view. I really appreciate all the advice

2021-09-24 13:56:29    分类:问答    ruby-on-rails   ruby-on-rails-3

Issues with DISTINCT when used in conjunction with ORDER

I am trying to construct a site which ranks performances for a selection of athletes in a particular event - I have previously posted a question which received a few good responses which me to identify the key problem with my code currently. I have 2 models - Athlete and Result (Athlete HAS MANY Results) Each athlete can have a number of recorded times for a particular event, i want to identify the quickest time for each athlete and rank these quickest times across all athletes. I use the following code: <% @filtered_names = Result.where(:event_name => params[:justevent]).joins(:athlete).order

2021-09-24 07:45:30    分类:问答    sql   ruby-on-rails   ruby-on-rails-3

Rails 3 and SQLite communications concerning boolians

im using Rails 3.2.8 and SQLite 1.3.6 and im running into troubles changing boolian variables in the database SQLite translates "t" and "f" as true and false this function wont update the :approved attribute (that is default false) def activate @user = User.find(params[:id]) if @user.update_attribute(:approved, 't') redirect_to "/" #this is the return i get so the update returns true else render "/users?approved=false" end end But changing strings like @user.update_attribute(:email,'root@email.org') will update the email how can i fix this do i need some kind of an sqlite adapter ? i already

2021-09-24 07:27:25    分类:问答    ruby-on-rails-3   sqlite   boolean   windows-7-x64