Search Results

Search found 9437 results on 378 pages for 'rails newbie'.

Page 107/378 | < Previous Page | 103 104 105 106 107 108 109 110 111 112 113 114  | Next Page >

  • Problem with fetching mail using TMail in Ruby on Rails

    - by Shreyas Satish
    While fetching email, TMail appears to parse the email body twice,when I use this code.All the other parameters are fine(from_email,email_subject). Any ideas? def get_mail Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE) Net::POP3.start('pop.gmail.com', 995, "uname","pass") do |pop| mail_header=[];mail_subject=[];mail_body=[];mail_from=[] unless pop.mails.empty? pop.each_mail do |mail| email = TMail::Mail.parse(mail.pop) mail_subject = email.subject mail_body = email.body mail_from = email.from email_obj=EmailedQueries.new email_obj.save_email(mail_from, mail_subject, mail_body) end end end end

    Read the article

  • jquery multiple select x rails edit action

    - by VP
    Hi, i'm using the JQUERY multiselectable plugin. Because it's get one select box and transform it in two, where you can move one selected option to another select box. The problem is that i'm facing some problems with the edit action. When i load the form, the selected values (that are saved in my model) are not being populated in the "selected" select box. There is anybody with a good idea about how to "automatically" move the selected values in my database from the "available to be selected" to "selected" options? For now i'm doing something like <%= select "product", :option_ids, options_for_select(Option.all.map { |opt| [opt.description, opt.id]}), {},{:multiple=> true,:class=>'multiselect'} %> Here i can see already the problem. I could just use as options_for_select just all options - the options that are already choosed in my model. The problem is how to update the select box with this information?

    Read the article

  • FBML + jquery Validation + Rails

    - by user359467
    Hi all, In my local machine i have a scaffold that uses Jquery Validation plugin for the field's validation. Now i want to add that to a fbml facebook application, but i'm haven't been able to load the jquery javascript and the jquery Validation plugin into the app, does anybody now how to do that? or maybe someone could suggest me a better way of doing validation inside a facebook application. Thanks in Advance Ernesto Carrión

    Read the article

  • Bootstrap Modal & rails remote

    - by Kevin Brown
    Using this bootstrap modal extension and animate.css for fun, how can I take a make an easy ajax modal using :remote => true to fill in the modal box? Also, how would I use the bootstrap modal default "submit/cancel" buttons to interact with a form that's loaded? I'm looking for a more dynamic solution instead of hard-html-ing every modal into the page or using a bunch of jquery ajax calls for each dialog. I've done a few quick searches, but they've turned up nil for this particular solution.

    Read the article

  • Rails problem with Delayed_Job and Active Record

    - by Michael Waxman
    I'm using Delayed_Job to grab a Twitter user's data from the API, but it's not saving it in the model for some reason! Please help! (code below) class BandJob < Struct.new(:band_id, :band_username) #parameter def perform require 'json' require 'open-uri' band = Band.find_by_id(band_id) t = JSON.parse(open("http://twitter.com/users/show/#{band_username}.json").read) band.screen_name = t['screen_name'] band.profile_background_image = t['profile_background_image_url'] band.url = 'http://' + band_username + '.com' band.save! end end To clarify, I'm actually not getting any errors, it's just not saving. Here's what my log looks like: * [JOB] acquiring lock on BandJob [4;36;1mDelayed::Job Update (3.1ms)[0m [0;1mUPDATE "delayed_jobs" SET locked_at = '2009-11-09 18:59:45', locked_by = 'host:dhcp128036151228.central.yale.edu pid:2864' WHERE (id = 10442 and (locked_at is null or locked_at < '2009-11-09 14:59:45') and (run_at <= '2009-11-09 18:59:45')) [0m [4;35;1mBand Load (1.5ms)[0m [0mSELECT * FROM "bands" WHERE ("bands"."id" = 34) LIMIT 1[0m [4;36;1mBand Update (0.6ms)[0m [0;1mUPDATE "bands" SET "updated_at" = '2009-11-09 18:59:45', "profile_background_image" = 'http://a3.twimg.com/profile_background_images/38193417/fbtile4.jpg', "url" = 'http://Coldplay.com', "screen_name" = 'coldplay' WHERE "id" = 34[0m [4;35;1mDelayed::Job Destroy (0.5ms)[0m [0mDELETE FROM "delayed_jobs" WHERE "id" = 10442[0m * [JOB] BandJob completed after 0.5448 1 jobs processed at 1.8011 j/s, 0 failed ... Thanks!

    Read the article

  • Rails callback for the equivalent of "after_new"

    - by Joe Cairns
    Right now I cant find a way to generate a callback between lines 1 and 2 here: f = Foo.new f.some_call f.save! Is there any way to simulate what would be effectively an after_new callback? Right now I'm using after_initialize but there are potential performance problems with using that since it fires for a lot of different events.

    Read the article

  • Using FlexMock in a rails functional test.

    - by dagda1
    Hi, I have the following index action: class ExpensesController < ApplicationController def index() @expenses = Expense.all end end I want to mock the call to all in a functional test. I am using flexmock and have written the following test: require 'test_helper' require 'flexmock' require 'flexmock/test_unit' class ExpensesControllerTest < ActionController::TestCase test "should render index" do flexmock(Expense).should_receive(:all).and_return([]) get :index assert_response :success assert_template :index assert_equal [], assigns(:presentations) end end The problem is the the last assertion fais with the following error message: <[] expected but was nil I am confused what I am doing wrong. Should this not work? Cheers Paul

    Read the article

  • Rails: validates_acceptance_of acting crazy

    - by Sleepycat
    Whats wrong with this picture? Model: validates_acceptance_of :terms_of_service, :on => :create, :accept => true, :allow_nil => false accessor :terms_of_service View: <%= check_box :organisation,'terms_of_service', {:style => "margin-left:0px"}, 1, 0 %> And in the DB I have organisations.terms_of_service. Every time I get "Terms of service must be accepted" Any ideas?

    Read the article

  • Rails Association issue with NoMethodError in event_controller

    - by pmanning
    Kinda a noob trying to understand I think I need to define rsvps but not sure what to put... I'm trying to add a Join/Unjoin button to user created Events, similar to a Follow/Unfollow button for Users. NoMethodError in Events#show undefined method `model_name' for NilClass:Class in line #1 _unjoin.html.erb 1: <%= form_for(current_user.rsvps.find_by_joined_id(@event), 2: html: { method: :delete }) do |f| %> 3: <%= f.submit "Leave", class: "btn btn-large" %> 4: <% end %> events_controller.rb def show @event = Event.find(params[:id]) @user = current_user end Here's the models rsvp.rb class Rsvp < ActiveRecord::Base attr_accessible :joined_id belongs_to :joiner, class_name: "User" belongs_to :joined, class_name: "User" validates :joiner_id, presence: true validates :joined_id, presence: true end user.rb has_many :rsvps, foreign_key: "joiner_id", dependent: :destroy has_many :joined_events, through: :rsvps, source: :joined has_many :reverse_rsvps, foreign_key: "joined_id", class_name: "Rsvp", dependent: :destroy has_many :joiners, through: :reverse_rsvps, source: :joiner event.rb belongs_to :user has_many :rsvps, foreign_key: "joiner_id", dependent: :destroy has_many :joined_events, through: :rsvps, source: :joined has_many :reverse_rsvps, foreign_key: "joined_id", class_name: "Rsvp", dependent: :destroy has_many :joiners, through: :reverse_rsvps, source: :joiner

    Read the article

  • Read from params[] in Rails

    - by Adnan
    Hi, I use: <%= select( "payment", "id", { "Visa" => "1", "Mastercard" => "2"}) %> and I get this in HTML <select id="payment_id" name="payment[id]"><option value="2">Mastercard</option> <option value="1">Visa</option></select> now how can I read the payment[id] with params[], if I use params[payment[id]] I get an error.

    Read the article

  • Rails 3 query in multiple date ranges

    - by NeoRiddle
    Suppose we have some date ranges, for example: ranges = [ [(12.months.ago)..(8.months.ago)], [(7.months.ago)..(6.months.ago)], [(5.months.ago)..(4.months.ago)], [(3.months.ago)..(2.months.ago)], [(1.month.ago)..(15.days.ago)] ] and a Post model with :created_at attribute. I want to find posts where created_at value is in this range, so the goal is to create a query like: SELECT * FROM posts WHERE created_at BETWEEN '2011-04-06' AND '2011-08-06' OR BETWEEN '2011-09-06' AND '2011-10-06' OR BETWEEN '2011-11-06' AND '2011-12-06' OR BETWEEN '2012-01-06' AND '2012-02-06' OR BETWEEN '2012-02-06' AND '2012-03-23'; If you have only one range like this: range = (12.months.ago)..(8.months.ago) we can do this query: Post.where(:created_at => range) and query should be: SELECT * FROM posts WHERE created_at BETWEEN '2011-04-06' AND '2011-08-06'; Is there a way to make this query using a notation like this Post.where(:created_at => range)? And what is the correct way to build this query? Thank you

    Read the article

  • rails xml to active record object

    - by Brian D.
    I've been googling for a while to try and convert and incoming XML request into an active record object. I've tried using the ActiveRecordObject.new.from_xml method but it doesn't seem to handle relationships. For example, say I have the following xml: <blog> <title></title> <blog-pages> <blog-page> <page-number></page-number> <content></content> </blog-page> </blog-pages> </blog> And I have the following model objects: class Blog < ActiveRecord::Base has_many :blog_pages end class BlogPage < ActiveRecord::Base belongs_to :blog end Is there a way to convert the xml into a blog object WITH relationships? Or do I need to manually parse the XML? Thanks in advance.

    Read the article

  • Rails will_paginate custom route

    - by kristian nissen
    How can I use will_paginate with a custom route? I have the following in my routes: map.connect 'human-readable/:name', :controller => :tags, :action => 'show' but will_paginate uses url_for as far as I can tell, but I want to use 'human-readable' instead of url_for, but how?

    Read the article

  • Rails editing multiple records at once

    - by Joseph Silvashy
    I feel like this might be really simple but I'm just not getting it right, so I have like a settings page in my app and I want each setting to be like a key value store, for example: +-------------------+--------------------------------+ | setting | value | +-------------------+--------------------------------+ | twitter_username | something | +-------------------+--------------------------------+ | facebook_url | http://facebook.com/someguy | +-------------------+--------------------------------+ My form looks something like this: <% form_tag set_admin_settings_path, :method => :put do %> <ol> <% for setting in @settings %> <li class="field"> <label><%= setting.setting_name.humanize %></label> <%= text_field_tag "[setting_value][]", setting.setting_value %> </li> <% end %> <li class="submit"> <%= submit_tag "Update settings" %> </li> </ol> <% end %> Everything renders fine but when I try to save the form, nothing is saved :(

    Read the article

  • Rails, different routes for production app.

    - by Joseph Silvashy
    Well, maybe not just different routes. Here is the issue at hand, we have an app that we want to present the users with a "beta sign-up" form when the app is running in production, but we still want to be able to login, however in development the app should function normally. For example in development the app's root path would be the page that show's all the products (using a store as an example) but in production we want the app to present the user with a beta page that just has a form for leaving an email, but also be able to sign-in for users that have accounts. We don't need any help with authentication, that's all sorted out more just the setup of redirecting users to the beta page in production so they can't explore the site unless they are logged in. We are using Devise so I thought maybe we could put something in our application controller that's like: before_filter :authenticate_user! if ENV['RAILS_ENV'] == 'production' But that doesn't seem like it works.

    Read the article

  • Dynamically changing validations in Rails

    - by user94154
    I have a model with a validation. At runtime, I'd like to change a value of the validation. For example: in the model bid.rb: class Bid ActiveRecord::Base @foo = Foo.find(1) validates_inclusion_of :amt, :in => [email protected], :message => "must be between 1 and #{@foo.bar}" end and in the application_controller (pseudocode): if today == 'wednesday' Foo.update(1, :bar => 10) else Foo.update(1, :bar => 5) end However, this setup isn't working. The "foo" attribute never updates. It seems that the validation code is set only when the dev server starts and then doesn't change.

    Read the article

  • Rails route hanging

    - by Bob
    I'm trying to get someone else's app up and running on my development laptop but I ran into a routing issue and I'm not sure how to debug it. For a particular controller/action, it just hangs and doesn't time out and there is no error message in the development log. Does anyone know how I can debug this? Thanks.

    Read the article

  • rails rollback updates when task fails

    - by ash34
    Hi, I have the following "generate_report" method being called from a rake task, which gets a hash as an input, that contains the reported hours spent by each user on a task and outputs the data as a .csv report. desc "Task reporting" task :report, [:inp_dt] => [:environment] do |t, args| h = select_data(args.inp_dt) /* not shown here */ generate_report(h) end def generate_report(h) out_dir = File.dirname(__FILE__) + '/../../output' myfile = "#{out_dir}" + "/monthly_#{Date.today.strftime("%m%d%Y")}.csv" writer = CSV.open(myfile, 'w') h.each do |h,v| v.each do |key,val| writer << val end end writer.close end where h = {:BILL=>{:PROJA=>["CYR", "00876", "2", 24], :PROJB=>["EPR", "00876", "2", 16]}, :JANE=>{:PROJA=>["TRB", "049576", "2", 16]}} I would like to set/update a 'processed' flag for each reported transaction and only commit the update when the file is written correctly or rollback the updates when the task fails. How can I accomplish this. thanks, ash

    Read the article

  • where can I find the rake tasks delivered with rails

    - by ash34
    I am looking for tasks like tmp:clear or db:migrate. Where can I find the code for these tasks. I remember seeing them before but don't recollect where. Also, is there a way I can set some global variables in a .rake file that can be accessed by all tasks in that file without passing them as arguments to each task. thanks, ash

    Read the article

  • Rails: include index with fields_for form helper

    - by Patrick Oscity
    i'm trying to build two models from one form by using the fields_for method. my code looks like this: <% for scale in @event.scales %> <% f.fields_for "scale[]", scale do |scale_form| %> <p> Scale<br /> <%= scale_form.label :name %> <%= scale_form.text_field :name %> <%= scale_form.label :price %> <%= scale_form.text_field :price %> </p> <% end %> <% end %> but unfortunately the output html is missing the id's of the scales: <p> Scale<br /> <label for="event_scale__name">Name</label> <input id="event_scale__name" name="event[scale][][name]" size="30" type="text" /> <label for="event_scale__price">Price</label> <input id="event_scale__price" name="event[scale][][price]" size="30" type="text" /> </p> ... here's the corresponding controller and model: class EventsController < ApplicationController ... def new @event = Event.new @providers = Provider.find(:all, :order => :name) 3.times { @event.scales.build } respond_to do |format| format.html end end ... end class Event < ActiveRecord::Base has_many :scales ... end what am i doing wrong?

    Read the article

  • Accessing the params hash for year and month rails and using in helper

    - by Matt
    So I took some php code and turned it into a calendar with a helper to make a simple calendar. I got my data from inside the helper: def calendar_maker a = Time.now b = a.month d = a.year h = Time.gm(d,b,1) #first day of month Now I want to try and do it with parameters within my method #from the helper file def calendar_maker(year, month) a = Time.now b = month c = year h = Time.gm(d,b,1) #first day of month #from my html.erb file <%= @month %> and <%= @year %> <%= params["month"] %><br /> <%= params["action"] %><br /> <%= params["year"] %><br /> <%= calendar_maker( @year, @month) %> #from controller file def calendar @month = params[:month] @year = params[:year] end Anyways mistakes were made and not finding documentation anywhere or not looking in the right place. How do I get this to work with my params hash. Thanks for the help.

    Read the article

< Previous Page | 103 104 105 106 107 108 109 110 111 112 113 114  | Next Page >