ruby-on-rails-3

Using Ruby/Rails To Programmatically Post Form Data To Another Site

﹥>﹥吖頭↗ 提交于 2020-01-06 08:31:28
问题 I'm trying to figure out a way to automate posting data on this site which does not have an API and thankfully not a captcha as well. For example there is a form here => http://www.austinchronicle.com/gyrobase/EventSubmission By examining the form I can figure out that the Name text box is setup as follows...... <input type="text" name="Name" id="EventName" value="" class="rejectPipe"> Using Ruby/Rails is there a way I can programmatically POST to the form on that page through the controller

Pulling CSS assets (like background images) from the database in a Rails app?

孤者浪人 提交于 2020-01-06 08:30:29
问题 I'm wondering if there's a way to store CSS asset paths, like background images, in the database so that they're customizable without accessing or rewriting the code. I've looked at some template engines, like liquid, but think they're a overkill for what I want to do. I only want a tiny bit of customization in my views between various deployments of the same app codebase, not anything for various users. I've not looked much at Rails 3.1, but from what I understand the CSS assets are compiled

Rails :include doesn't include

邮差的信 提交于 2020-01-06 08:18:36
问题 My models: class Contact < ActiveRecord::Base has_many :addresses has_many :emails has_many :websites accepts_nested_attributes_for :addresses, :emails, :websites attr_accessible :prefix, :first_name, :middle_name, :last_name, :suffix, :nickname, :organization, :job_title, :department, :birthday, :emails_attributes end class Email < ActiveRecord::Base belongs_to :contact validates_presence_of :account validates_format_of :account, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :on =>

Rails, has one Country and has many ExportCountries?

梦想与她 提交于 2020-01-06 08:17:25
问题 I have a Listing model and a Country model. Each listing has a country (as part of it's address details), but each listing can also have several ExportCountries (which are just countries the listing owner exports to). A listing has_one country A Country has_many listings A listing has_and_belongs_to_many ExportCountries An ExportCountry has_and_belongs_to_many Listings If I had two separate models I would probably do this: class Listing < ActiveRecord::Base belongs_to :country has_and_belongs

Resque and Resque_mailer with Devise

拈花ヽ惹草 提交于 2020-01-06 07:53:07
问题 I am implementing background email processing with Resque using the resque_mailer gem (https://github.com/zapnap/resque_mailer). I was able to get it to work for all my emails except the ones sent by Devise. I went through a bunch of SO questions, and blog posts (for instance http://teeparham.posterous.com/send-devise-emails-with-resque) but could not find a way to get it to work. What are the precise steps to follow to get resque_mailer to work with Devise? 回答1: I'd take a look at devise

how can i implement parent-child relationship in rails3

非 Y 不嫁゛ 提交于 2020-01-06 07:11:43
问题 I'm creating a billing application in rails3, I have a confusion when it comes to creating a bill. one bill can have one or more items 'bill' has many 'items' 'item' belongs to 'bill' my requirement is as follows I should be able to create a new bill and add items to it (any number of items can be added) my problem is 1 - to get items to be saved in the bill_details table I should first generate bill_id, What is the best way to generate this bill id. 2 - what is the best way to implement a

how can i implement parent-child relationship in rails3

点点圈 提交于 2020-01-06 07:11:07
问题 I'm creating a billing application in rails3, I have a confusion when it comes to creating a bill. one bill can have one or more items 'bill' has many 'items' 'item' belongs to 'bill' my requirement is as follows I should be able to create a new bill and add items to it (any number of items can be added) my problem is 1 - to get items to be saved in the bill_details table I should first generate bill_id, What is the best way to generate this bill id. 2 - what is the best way to implement a

How do I show all the stages (one model) that belong to a project (another model) in Rails 3?

徘徊边缘 提交于 2020-01-06 07:10:44
问题 I have two controllers: projects and stages. Projects has many stages and stages belongs to projects. I want when you click on the name of the project (i.e. the projects show action), for it to show all the stages related to that project. How do I do that ? All of the relevant code can be found below: Stages Controller class StagesController < ApplicationController filter_resource_access # GET /stages # GET /stages.xml def index @stages = Stage.all respond_to do |format| format.html # index

Undefined method <model_name>_index_path for rails 3.2

孤者浪人 提交于 2020-01-06 07:00:20
问题 Okay, this continues to baffle me: 1) This is in my controller (personalias_controller.rb) def new @personalia = Personalia.new end 2) I've got a model called personalia.rb 3) I've got resources :personalias in routes.rb Still I get undefined method `personalia_index_path' when I try to render the personalia form as such (from within views/personalias/new.html.erb: <%= form_for @personalia do |f| %> It's driving me nuts :-| 回答1: It is probably becouse personalias is not the plural of

Rails using a join model attribute in a condition for a find

末鹿安然 提交于 2020-01-06 06:45:36
问题 I'm using a :has_many, :through association to link two models, User and Place It looks like this - In User: has_many :user_places has_many :places, :through=>:user_places In Place: has_many :user_places has_many :users, :through=>:user_places In User_Place belongs_to :user belongs_to :place belongs_to :place_status On that last one note the place_status. I want to write a find that returns all places associated to a user with a particular place_status_id. Place_Status_id is on the join model