ruby-on-rails-3

Can't create Custom inputs for some (Text, Booleans, …) types, with SimpleForm

百般思念 提交于 2019-12-23 05:43:11
问题 I can't figure out why this is not working as it should - or - I'm missing something important ? Here's the list of the mapped types from simple_form / lib / simple_form / form_builder.rb : map_type :text, :to => SimpleForm::Inputs::TextInput map_type :file, :to => SimpleForm::Inputs::FileInput map_type :string, :email, :search, :tel, :url, :to => SimpleForm::Inputs::StringInput map_type :password, :to => SimpleForm::Inputs::PasswordInput map_type :integer, :decimal, :float, :to => SimpleForm

Rails -Namespace Css Not Working

*爱你&永不变心* 提交于 2019-12-23 05:37:28
问题 I am trying to implement a admin namespace into my web application . It is working fine on my local machine but when I am trying to deploy the application none of my css is working. I tried rake assets:precompile I have restarted the server .My structure looks like this app assets stylesheets . application.css admin my_admin.css The same structure is with Javascripts.In my layout file I have used <%= stylesheet_link_tag "admin/my_admin" %> <%= javascript_include_tag "admin/my_admin" %> When I

accepts_nested_attributes not saving any changes

北慕城南 提交于 2019-12-23 05:35:08
问题 Maybe I'm missing something obvious (hopefully), but I'm encountering a weird problem saving records in a nested form. It's a pretty basic setup, with a minor complication in that my LineItem model is a two-word relationship (:line_items). However, I've followed Rails guidelines and it seems to be working OK. My fixtures are creating the proper relationships between line_items and invoices, and everything is showing up properly in my views, but I can't get any line_item records to save

Ruby on Rails gem 'byebug' installing error

泪湿孤枕 提交于 2019-12-23 05:34:13
问题 How can I fix this error? This issue is created when I check the rails version in a demo created website using this command. 回答1: you can also use another debugger gem 'pry', '0.9.12.6' and remove gem 'byebug' . Then run bundle install 回答2: The output in yellow is asking you to run bundle install instead of gem install You should do that. Update: It looks like the windows version build is failing. Only passes for ruby 2.0.0 but not for above versions. You can check the status at byebug's

Join two tables with condition - ruby on rails

柔情痞子 提交于 2019-12-23 05:33:09
问题 I wanna join 2 table, games and game_logs. I did it this: game_joins = Game.joins(:game_logs) It worked. But the thing is I only want to join where the player_id = 1(for example). Column player_id can only be found in table game_logs. So, when I do like this: game_joins = Game.joins(:game_logs).where(:player_id => 1) Column player_id can't be found, because Game.joins(:game_logs) will result : SELECT games.* FROM games INNER JOIN game_logs ON game_logs.game_id= game.id So, the question is

using a select, assign variable and retrieve records

拈花ヽ惹草 提交于 2019-12-23 05:31:23
问题 I am attempting what I would think is simple, but I have had zero luck in finding a solution that is similar AND easily adaptable to my problem. I have a view with a select dropdown which only contains months (January-December). I want the user to be able to choose a month and click a link_to button and retrieve a subset of records where the billDate field contains the month in question, I don't care about the day, and the records will always be the current year. I have used the following...

Regex to Match Urls in Ruby on Rails

空扰寡人 提交于 2019-12-23 05:27:44
问题 I have looked around but I haven't really found an answer that seals the deal 100% for my individual situation. In my Ruby app, I have a user share system where members can post 'stuff'. Well, sometimes members post links, and I have noticed as the site grows, more and more users are complaining about there not being clickable links. How would I utilize regular expressions to match urls for links in posts. Furthermore, how would I apply this in my Model? Thanks for you help, out of all my

Cannot find FakeInput

我是研究僧i 提交于 2019-12-23 05:27:44
问题 I am trying add a fake input to simple_form using the following suggestion (rails simple_form fields not related to the model), but it does not work for me. This is my HAML code for adding a fake input field. = f.input :agrees_to_terms, :as => :fake I put the following class in app/inputs/fake_input.rb class FakeInput < SimpleForm::Inputs::StringInput # This method only create a basic input without reading any value from object def input template.text_field_tag(attribute_name, nil, input_html

Rails route with resources :address - Singular & Plural

。_饼干妹妹 提交于 2019-12-23 05:22:46
问题 I have a route for addresses: namespace :carts do resources :address Yet it generates a mispelling for the new path, addres . Is this a bug in Rails 3.2.14? carts_address GET /carts/address(.:format) refinery/carts/address#index POST /carts/address(.:format) refinery/carts/address#create new_carts_addres GET /carts/address/new(.:format) refinery/carts/address#new edit_carts_addres GET /carts/address/:id/edit(.:format) refinery/carts/address#edit carts_addres GET /carts/address/:id(.:format)

has_many through middle model not creating, but creating duplicate of one model

雨燕双飞 提交于 2019-12-23 05:21:02
问题 I have two models join by a middle model class Integration < ActiveRecord::Base has_many :integration_records has_many :records, through: :integration_records end class IntegrationRecord < ActiveRecord::Base belongs_to :integration belongs_to :record end class Record < ActiveRecord::Base has_many :integration_records has_many :integrations, through: :integration_records end i = Integration.create(whatever) i.records.create(whatever) => (0.1ms) BEGIN SQL (8.7ms) INSERT INTO "records" ("created