Search Results

Search found 3 results on 1 pages for 'dombesz'.

Page 1/1 | 1 

  • Sql query Error: Operand should contain 1 column(s) in rails

    - by dombesz
    Hi everyone, SELECT * FROM jobs WHERE (SELECT DISTINCT jobs.* FROM jobs, job_requests WHERE (jobs.user_id = 1) OR (job_requests.user_id = 1 AND job_requests.job_id = jobs.id)) This sql gives me Mysql::Error: Operand should contain 1 column(s). If i execute the select from the where clause it works SELECT DISTINCT jobs.* FROM jobs, job_requests WHERE (jobs.user_id = 1) OR (job_requests.user_id = 1 AND job_requests.job_id = jobs.id) Could somebody explain me why? This query is generated by rails activerecord so the main select is needed.

    Read the article

  • Eager load this rails association

    - by dombesz
    Hi, I have rails app which has a list of users. I have different relations between users, for example worked with, friend, preferred. When listing the users i have to decide if the current user can add a specific user to his friends. -if current_user.can_request_friendship_with(user) =add_to_friends(user) -else =remove_from_friends(user) -if current_user.can_request_worked_with(user) =add_to_worked_with(user) -else =remove_from_worked_with(user) The can_request_friendship_with(user) looks like: def can_request_friendship_with(user) !self.eql?(user) && !self.friendships.find_by_friend_id(user) end My problem is that this means in my case 4 query per user. Listing 10 users means 40 query. Could i somehow eager load this?

    Read the article

  • Rails partial gets double escaped when using link_to_function

    - by dombesz
    Hi, I have the following code. def add_resume_link(name, form) link_to_function name do |page| html = form.fields_for :resumes, @general_resume.resumes.build, :child_index => 'NEW_RECORD' do |form_parent| render :partial => 'resume_form', :locals=>{:form=>form_parent} end page << "$('resumes').insert({ bottom: '#{escape_javascript(html)}'.replace(/NEW_RECORD/g, id) });" end end And on the resume_form i have somewhere: =add_skill_link("Add Skill", form, "resume_#{id}_skills") and the function looks like: def add_skill_link(name, form, id) link_to_function name do |page| html = form.fields_for :skill_items, @general_resume.skill_items.build, :child_index => 'NEW_RECORD' do |form_parent| render :partial=>'skill_form', :locals=>{:form=>form_parent, :parent=>id} end page << "$('#{id}').insert({ bottom: '#{escape_javascript(html)}'.replace(/NEW_RECORD/g, new Date().getTime()) });" end end So basically i have a javascript code which dinamically adds a piece of html (add_resume) and contains another javascript code which dinamically adds a select box to the page. My problem is that the add_skill_link works fine if i use from the server side, i mean rendering from server side. And gets double escaped when using within the upper described way. I tried to remove the escape_javascript from the add_skill_link bit still not good. Any ideas?

    Read the article

1