ruby-on-rails-3.1

API for Android OS in ruby on rails

蹲街弑〆低调 提交于 2019-12-08 05:06:32
问题 I need to provide an RESTful api to be developed in ruby on rails with CRUD features for an android app. I haven't worked with mobile phone OS(android/iphone) integration with RoR earlier. So, please help me getting started. Thanks in advance. 回答1: you can send the data as Json packets to the device and in device parse the json packets and access the data. your calls to webservice should be a http call eg this is for the client. http:\server\metnod\get_somedata?name=something and the server

How to call a controller's method from a view?

僤鯓⒐⒋嵵緔 提交于 2019-12-08 05:06:27
问题 I'm developing a small application in Ruby-On-Rails. I want to call a controller's method from a view. This method will only perform some inserts in the database tables. What's the correct way to do this? I've tried something like this but apparently the method code is not executed: <%= link_to 'Join', method: join_event %> 回答1: The method option in a link_to method call is actually the HTTP method, not the name of the action. It's useful for when passing the HTTP Delete option, since the

Redirect to root_path after failed Devise user registration

那年仲夏 提交于 2019-12-08 04:37:53
问题 I've read & attempted the solutions posted in numerous SO posts (i.e. here, here, and here) as well as Devise's answer on how to change the path after a failed registration, and Devise's RegistrationsController code, all to no avail. Instead of doing the custom failure method in the /lib/ folder like most suggest, It seems like the easiest place to fix/override this would be in the RegistrationsController#create method at the bottom where it's: else clean_up_passwords resource respond_with

Spork + Minitest

自闭症网瘾萝莉.ら 提交于 2019-12-08 04:26:36
问题 Can anyone explain how to use Spork with Minitest. I see there's a spork-minitest gem, but it's not clear how to use it. 回答1: after you add it to your Gemfile, you can use the docs at https://github.com/sporkrb/spork and substitute in 'minitest'. so you can do spork minitest --bootstrap then to run tests, spork-minitest provides a testdrb which you can pass tests into so testdrb test/unit/something_test.rb 来源: https://stackoverflow.com/questions/9932384/spork-minitest

Is passing multiple params to thinking_sphinx search method absolutely impossible?

非 Y 不嫁゛ 提交于 2019-12-08 04:23:39
问题 I have a page that when visted brings up the most recently active users. Above the users are some filtering options such as filtering by one or a combination of: location gender sexual preference age range country I'm using a form_tag helper for my form. My issue is passing each of these parameters to my controller: class BrowsersController < ApplicationController def index @default_image = "/assets/default_avatar.jpg" @users = Profile.search params[:search], :page => params[:page], :per_page

Rails '.js.erb' not rendering partial

爱⌒轻易说出口 提交于 2019-12-08 04:12:56
问题 So, i'm working with rails 3.2.13 and what i'm trying to do is render a partial and then append it to a div using jquery: $("#notifications").append("<%=raw escape_javascript(render('layouts/notification')) %>"); what it does right now, is it appends it to the right div but it doesn't render the partial or anything, it just renders the rails code as a string.. I don't know what i'm doing wrong but i bet its something silly that i'm missing. Any help would be appreciated thanks 回答1: Try render

Putting Javascript at the end of the file using Rails 3.1 asset pipeline

别来无恙 提交于 2019-12-08 04:07:12
问题 Sometimes in heavy client side Javascript we put the tags at the end of the HTML file so that the content is displayed first while Javascript is loaded afterwards. Is it possible to do this using Rails 3.1 assets pipeline? EDIT: <html> <head> <%= javascript_include_tag "application" %> </head> <body> <!-- all the page content goes here --> <!-- we include these at the bottom to ensure the html loads first and the javascript is loaded afterwards. How can we achieve this through rails asset

stringify_keys error after supplementing session variables in functional tests

二次信任 提交于 2019-12-08 04:00:26
问题 I'm in the process of upgrading to Rails 3.1.0 from 3.0.10, and I'm using Devise for authentication. I have a number of functional tests that require me to set a single session variable. Stuff along the lines of: test "new clears current_lesson_id from session" do get :new, nil, {'current_lesson_id' => '234234'} assert_response :success assert_nil session[:current_lesson_id] end This was failing as my session info was clobbering the devise authentication session data, so my previous solution

windows 7 with rails 3.1 error

送分小仙女□ 提交于 2019-12-08 03:59:55
问题 Error after scaffold with rails 3.1 I am trying to use the rail 3.1.1 I installed gem therubytrace and exjs on my rails I use windows 7, but cannot seem to get them to work together.It gives me error when i execute rails command rails generate scaffold status name:string code:string I get the following: I type command rails generate scaffold status code:string name:string enter code here g++ -shared -s -o v8.so rr.o v8.o v8_array.o v8_callbacks.o v8_context.o v8_date .o v8_debug.o v8

Something's wrong with assets - each page in local takes over 1.5 mins to load

天涯浪子 提交于 2019-12-08 03:59:28
问题 Since I moved to active_admin my local server takes over 1.5 minutes to load each and every page. I'm surely doing something wrong. Development.rb config.assets.compress = true; config.assets.debug = true; config.assets.compile = false; config.assets.digest = false Production.rb config.assets.compress = true; config.assets.compile = true; config.assets.digest = true; config.assets.precompile += ['active_admin.js', 'active_admin.css'] Note the compile is true in production because active admin