stackoverfeeds 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +121 -0
- data/Rakefile +32 -0
- data/app/assets/javascripts/stackoverfeeds/application.js +13 -0
- data/app/assets/stylesheets/stackoverfeeds/application.css +13 -0
- data/app/controllers/stackoverfeeds/application_controller.rb +4 -0
- data/app/controllers/stackoverfeeds/so_feeds_controller.rb +10 -0
- data/app/helpers/stackoverfeeds/application_helper.rb +4 -0
- data/app/helpers/stackoverfeeds/stackoverfeeds_helper.rb +8 -0
- data/app/models/stackoverfeeds/so_feed.rb +9 -0
- data/app/views/stackoverfeeds/_stackoverflow_feeds.html.erb +28 -0
- data/app/views/stackoverfeeds/application.html.erb +14 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20140402191249_create_stackoverfeeds_so_feeds.rb +14 -0
- data/lib/generators/stackoverfeeds/install/install_generator.rb +74 -0
- data/lib/generators/stackoverfeeds/install/templates/application.css +7 -0
- data/lib/generators/stackoverfeeds/install/templates/application.js +16 -0
- data/lib/generators/stackoverfeeds/install/templates/config.yml +14 -0
- data/lib/generators/stackoverfeeds/install/templates/feeds.css +791 -0
- data/lib/generators/stackoverfeeds/install/templates/feeds.js +21 -0
- data/lib/generators/stackoverfeeds/install/templates/schedule.rb +7 -0
- data/lib/generators/stackoverfeeds/install/templates/sprites.png +0 -0
- data/lib/stackoverfeeds.rb +4 -0
- data/lib/stackoverfeeds/engine.rb +11 -0
- data/lib/stackoverfeeds/stackoverfeeds_handler.rb +34 -0
- data/lib/stackoverfeeds/version.rb +3 -0
- data/lib/tasks/stackoverfeeds_tasks.rake +14 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +28 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20140403144550_create_stackoverfeeds_so_feeds.stackoverfeeds.rb +15 -0
- data/spec/dummy/db/schema.rb +27 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +19 -0
- data/spec/dummy/log/test.log +772 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/spec/helpers/stackoverfeeds_spec.rb +20 -0
- data/spec/dummy/spec/lib/stackoverfeeds_handler_spec.rb +17 -0
- data/spec/dummy/spec/models/so_feed_spec.rb +32 -0
- data/spec/dummy/spec/resources/member.atom +243 -0
- data/spec/dummy/spec/spec_helper.rb +18 -0
- data/spec/dummy/spec/support/blueprints.rb +10 -0
- metadata +256 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
background-color: #EFEFEF;
|
|
8
|
+
color: #2E2F30;
|
|
9
|
+
text-align: center;
|
|
10
|
+
font-family: arial, sans-serif;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
div.dialog {
|
|
14
|
+
width: 25em;
|
|
15
|
+
margin: 4em auto 0 auto;
|
|
16
|
+
border: 1px solid #CCC;
|
|
17
|
+
border-right-color: #999;
|
|
18
|
+
border-left-color: #999;
|
|
19
|
+
border-bottom-color: #BBB;
|
|
20
|
+
border-top: #B00100 solid 4px;
|
|
21
|
+
border-top-left-radius: 9px;
|
|
22
|
+
border-top-right-radius: 9px;
|
|
23
|
+
background-color: white;
|
|
24
|
+
padding: 7px 4em 0 4em;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
h1 {
|
|
28
|
+
font-size: 100%;
|
|
29
|
+
color: #730E15;
|
|
30
|
+
line-height: 1.5em;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
body > p {
|
|
34
|
+
width: 33em;
|
|
35
|
+
margin: 0 auto 1em;
|
|
36
|
+
padding: 1em 0;
|
|
37
|
+
background-color: #F7F7F7;
|
|
38
|
+
border: 1px solid #CCC;
|
|
39
|
+
border-right-color: #999;
|
|
40
|
+
border-bottom-color: #999;
|
|
41
|
+
border-bottom-left-radius: 4px;
|
|
42
|
+
border-bottom-right-radius: 4px;
|
|
43
|
+
border-top-color: #DADADA;
|
|
44
|
+
color: #666;
|
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
48
|
+
</head>
|
|
49
|
+
|
|
50
|
+
<body>
|
|
51
|
+
<!-- This file lives in public/404.html -->
|
|
52
|
+
<div class="dialog">
|
|
53
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
|
54
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
|
55
|
+
</div>
|
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
57
|
+
</body>
|
|
58
|
+
</html>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
background-color: #EFEFEF;
|
|
8
|
+
color: #2E2F30;
|
|
9
|
+
text-align: center;
|
|
10
|
+
font-family: arial, sans-serif;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
div.dialog {
|
|
14
|
+
width: 25em;
|
|
15
|
+
margin: 4em auto 0 auto;
|
|
16
|
+
border: 1px solid #CCC;
|
|
17
|
+
border-right-color: #999;
|
|
18
|
+
border-left-color: #999;
|
|
19
|
+
border-bottom-color: #BBB;
|
|
20
|
+
border-top: #B00100 solid 4px;
|
|
21
|
+
border-top-left-radius: 9px;
|
|
22
|
+
border-top-right-radius: 9px;
|
|
23
|
+
background-color: white;
|
|
24
|
+
padding: 7px 4em 0 4em;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
h1 {
|
|
28
|
+
font-size: 100%;
|
|
29
|
+
color: #730E15;
|
|
30
|
+
line-height: 1.5em;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
body > p {
|
|
34
|
+
width: 33em;
|
|
35
|
+
margin: 0 auto 1em;
|
|
36
|
+
padding: 1em 0;
|
|
37
|
+
background-color: #F7F7F7;
|
|
38
|
+
border: 1px solid #CCC;
|
|
39
|
+
border-right-color: #999;
|
|
40
|
+
border-bottom-color: #999;
|
|
41
|
+
border-bottom-left-radius: 4px;
|
|
42
|
+
border-bottom-right-radius: 4px;
|
|
43
|
+
border-top-color: #DADADA;
|
|
44
|
+
color: #666;
|
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
48
|
+
</head>
|
|
49
|
+
|
|
50
|
+
<body>
|
|
51
|
+
<!-- This file lives in public/422.html -->
|
|
52
|
+
<div class="dialog">
|
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
55
|
+
</div>
|
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
57
|
+
</body>
|
|
58
|
+
</html>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
background-color: #EFEFEF;
|
|
8
|
+
color: #2E2F30;
|
|
9
|
+
text-align: center;
|
|
10
|
+
font-family: arial, sans-serif;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
div.dialog {
|
|
14
|
+
width: 25em;
|
|
15
|
+
margin: 4em auto 0 auto;
|
|
16
|
+
border: 1px solid #CCC;
|
|
17
|
+
border-right-color: #999;
|
|
18
|
+
border-left-color: #999;
|
|
19
|
+
border-bottom-color: #BBB;
|
|
20
|
+
border-top: #B00100 solid 4px;
|
|
21
|
+
border-top-left-radius: 9px;
|
|
22
|
+
border-top-right-radius: 9px;
|
|
23
|
+
background-color: white;
|
|
24
|
+
padding: 7px 4em 0 4em;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
h1 {
|
|
28
|
+
font-size: 100%;
|
|
29
|
+
color: #730E15;
|
|
30
|
+
line-height: 1.5em;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
body > p {
|
|
34
|
+
width: 33em;
|
|
35
|
+
margin: 0 auto 1em;
|
|
36
|
+
padding: 1em 0;
|
|
37
|
+
background-color: #F7F7F7;
|
|
38
|
+
border: 1px solid #CCC;
|
|
39
|
+
border-right-color: #999;
|
|
40
|
+
border-bottom-color: #999;
|
|
41
|
+
border-bottom-left-radius: 4px;
|
|
42
|
+
border-bottom-right-radius: 4px;
|
|
43
|
+
border-top-color: #DADADA;
|
|
44
|
+
color: #666;
|
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
48
|
+
</head>
|
|
49
|
+
|
|
50
|
+
<body>
|
|
51
|
+
<!-- This file lives in public/500.html -->
|
|
52
|
+
<div class="dialog">
|
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
|
54
|
+
</div>
|
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'stackoverfeeds/stackoverfeeds_handler'
|
|
3
|
+
|
|
4
|
+
describe Stackoverfeeds::StackoverfeedsHelper do
|
|
5
|
+
|
|
6
|
+
describe 'stackoverflow_feeds' do
|
|
7
|
+
|
|
8
|
+
before :each do
|
|
9
|
+
link ="File://#{Rails.root}/spec/resources/member.atom"
|
|
10
|
+
StackoverfeedsHandler.fetch_and_create_feeds_enrties link
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context 'check content correctness' do
|
|
14
|
+
|
|
15
|
+
it 'has to render partial stackoverflow_feeds with atom entries' do
|
|
16
|
+
expect(stackoverflow_feeds 20).to match /It makes only one query./
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'stackoverfeeds/stackoverfeeds_handler'
|
|
3
|
+
|
|
4
|
+
describe StackoverfeedsHandler do
|
|
5
|
+
|
|
6
|
+
describe '.fetch_and_create_feeds_enrties' do
|
|
7
|
+
|
|
8
|
+
let(:link) { "File://#{Rails.root}/spec/resources/member.atom" }
|
|
9
|
+
|
|
10
|
+
it 'has to fetch entries from feeds' do
|
|
11
|
+
expect{ StackoverfeedsHandler.fetch_and_create_feeds_enrties(link) }.to change{ Stackoverfeeds::SoFeed.count }.by(11)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Stackoverfeeds::SoFeed do
|
|
4
|
+
|
|
5
|
+
describe 'attributes' do
|
|
6
|
+
it { should respond_to :entry_id }
|
|
7
|
+
it { should respond_to :published }
|
|
8
|
+
it { should respond_to :updated }
|
|
9
|
+
it { should respond_to :title }
|
|
10
|
+
it { should respond_to :author }
|
|
11
|
+
it { should respond_to :summary }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe 'methods' do
|
|
15
|
+
let(:feeds_entries) do
|
|
16
|
+
(1..12).each do
|
|
17
|
+
Stackoverfeeds::SoFeed.make!
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'return the MAX permitted size even there are more (with parameter equals 5)' do
|
|
22
|
+
feeds_entries
|
|
23
|
+
expect(Stackoverfeeds::SoFeed.public_feeds(5).length).to eq(5)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'returns results in the correct order' do
|
|
27
|
+
feeds_entries
|
|
28
|
+
entry = Stackoverfeeds::SoFeed.make!(published: Time.now + 2.days)
|
|
29
|
+
expect(Stackoverfeeds::SoFeed.public_feeds.first.id).to eq(entry.id)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
|
|
3
|
+
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:re="http://purl.org/atompub/rank/1.0">
|
|
4
|
+
<title type="text">User VAIRIX - Stack Overflow</title>
|
|
5
|
+
<link rel="self" href="http://stackoverflow.com/feeds/user/3470100" type="application/atom+xml" />
|
|
6
|
+
<link rel="alternate" href="http://stackoverflow.com/users/3470100" type="text/html" />
|
|
7
|
+
<subtitle>most recent 30 from stackoverflow.com</subtitle>
|
|
8
|
+
<updated>2014-04-02T17:00:30Z</updated>
|
|
9
|
+
<id>http://stackoverflow.com/feeds/user/3470100</id>
|
|
10
|
+
<creativeCommons:license>http://www.creativecommons.org/licenses/by-sa/3.0/rdf</creativeCommons:license>
|
|
11
|
+
|
|
12
|
+
<entry>
|
|
13
|
+
<id>http://stackoverflow.com/questions/22795691/-/22797446#22797446</id>
|
|
14
|
+
<re:rank scheme="http://stackoverflow.com">0</re:rank>
|
|
15
|
+
<title type="text">Answer by VAIRIX for Joining a table and a filtered table in ActiveRecord</title>
|
|
16
|
+
<author>
|
|
17
|
+
<name>VAIRIX</name>
|
|
18
|
+
<uri>http://stackoverflow.com/users/3470100</uri>
|
|
19
|
+
</author>
|
|
20
|
+
<link rel="alternate" href="http://stackoverflow.com/questions/22795691/joining-a-table-and-a-filtered-table-in-activerecord/22797446#22797446" />
|
|
21
|
+
<published>2014-04-01T21:41:35Z</published>
|
|
22
|
+
<updated>2014-04-01T21:41:35Z</updated>
|
|
23
|
+
<summary type="html"><p>You can do something like this:</p>
|
|
24
|
+
|
|
25
|
+
<pre><code>Song.joins(:albums).where('albums.released_on &gt;= ?', from).where('albums.rating &gt; ?', rating).where('albums.genre = ?', genres)
|
|
26
|
+
</code></pre>
|
|
27
|
+
|
|
28
|
+
<p>It makes only one query.</p>
|
|
29
|
+
</summary>
|
|
30
|
+
</entry>
|
|
31
|
+
<entry>
|
|
32
|
+
<id>http://stackoverflow.com/questions/22796203/in-rails-4-using-ajax-how-do-i-update-a-particular-div-on-success/22796990#22796990</id>
|
|
33
|
+
<re:rank scheme="http://stackoverflow.com">0</re:rank>
|
|
34
|
+
<title type="text">Answer by VAIRIX for In Rails 4 using AJAX, how do I update a particular div on success?</title>
|
|
35
|
+
<author>
|
|
36
|
+
<name>VAIRIX</name>
|
|
37
|
+
<uri>http://stackoverflow.com/users/3470100</uri>
|
|
38
|
+
</author>
|
|
39
|
+
<link rel="alternate" href="http://stackoverflow.com/questions/22796203/in-rails-4-using-ajax-how-do-i-update-a-particular-div-on-success/22796990#22796990" />
|
|
40
|
+
<published>2014-04-01T21:13:17Z</published>
|
|
41
|
+
<updated>2014-04-01T21:13:17Z</updated>
|
|
42
|
+
<summary type="html"><p>This should work for you:</p>
|
|
43
|
+
|
|
44
|
+
<pre><code>html = render_to_string(partial: 'images', locals: {user: user})
|
|
45
|
+
</code></pre>
|
|
46
|
+
</summary>
|
|
47
|
+
</entry>
|
|
48
|
+
<entry>
|
|
49
|
+
<id>http://stackoverflow.com/questions/22761911/-/22762973#22762973</id>
|
|
50
|
+
<re:rank scheme="http://stackoverflow.com">0</re:rank>
|
|
51
|
+
<title type="text">Answer by VAIRIX for How to implement root route and get "index" to the same page</title>
|
|
52
|
+
<author>
|
|
53
|
+
<name>VAIRIX</name>
|
|
54
|
+
<uri>http://stackoverflow.com/users/3470100</uri>
|
|
55
|
+
</author>
|
|
56
|
+
<link rel="alternate" href="http://stackoverflow.com/questions/22761911/how-to-implement-root-route-and-get-index-to-the-same-page/22762973#22762973" />
|
|
57
|
+
<published>2014-03-31T13:34:39Z</published>
|
|
58
|
+
<updated>2014-03-31T13:34:39Z</updated>
|
|
59
|
+
<summary type="html"><p>A possible solution that implies more than one line, is using scope to make it cleaner, you will have two extra lines of code, but I found it more readable:</p>
|
|
60
|
+
|
|
61
|
+
<pre><code>scope :path =&gt; '/', :controller =&gt; :static_pages do
|
|
62
|
+
get 'index' =&gt; :index, :as =&gt; 'index'
|
|
63
|
+
get 'home' =&gt; :index, :as =&gt; 'home'
|
|
64
|
+
end
|
|
65
|
+
</code></pre>
|
|
66
|
+
|
|
67
|
+
<p>That way you make explicit which controller to use for all routes + the path (first part of it).</p>
|
|
68
|
+
</summary>
|
|
69
|
+
</entry>
|
|
70
|
+
<entry>
|
|
71
|
+
<id>http://stackoverflow.com/questions/22762135/-/22762326#22762326</id>
|
|
72
|
+
<re:rank scheme="http://stackoverflow.com">0</re:rank>
|
|
73
|
+
<title type="text">Answer by VAIRIX for I don't really know what RSPEC assigns do, and my tests are failing</title>
|
|
74
|
+
<author>
|
|
75
|
+
<name>VAIRIX</name>
|
|
76
|
+
<uri>http://stackoverflow.com/users/3470100</uri>
|
|
77
|
+
</author>
|
|
78
|
+
<link rel="alternate" href="http://stackoverflow.com/questions/22762135/i-dont-really-know-what-rspec-assigns-do-and-my-tests-are-failing/22762326#22762326" />
|
|
79
|
+
<published>2014-03-31T13:05:05Z</published>
|
|
80
|
+
<updated>2014-03-31T13:05:05Z</updated>
|
|
81
|
+
<summary type="html"><p>What you should expect from the assign after calling your controller, is to have the value that the controller sets to the instance variable. You could see it like using @category. So the category created with FactoryGirl is not equals to the one created by your controller (in this case seems your action is returning nil value in your instance variable)</p>
|
|
82
|
+
</summary>
|
|
83
|
+
</entry>
|
|
84
|
+
<entry>
|
|
85
|
+
<id>http://stackoverflow.com/questions/22720472/-/22720669#22720669</id>
|
|
86
|
+
<re:rank scheme="http://stackoverflow.com">1</re:rank>
|
|
87
|
+
<title type="text">Answer by VAIRIX for Select objects based on grandchild attribute with joins in ActiveRecord</title>
|
|
88
|
+
<author>
|
|
89
|
+
<name>VAIRIX</name>
|
|
90
|
+
<uri>http://stackoverflow.com/users/3470100</uri>
|
|
91
|
+
</author>
|
|
92
|
+
<link rel="alternate" href="http://stackoverflow.com/questions/22720472/select-objects-based-on-grandchild-attribute-with-joins-in-activerecord/22720669#22720669" />
|
|
93
|
+
<published>2014-03-28T18:35:10Z</published>
|
|
94
|
+
<updated>2014-03-28T18:35:10Z</updated>
|
|
95
|
+
<summary type="html"><p>This should be work!</p>
|
|
96
|
+
|
|
97
|
+
<pre><code>Foo.joins(:bazs).where(bazs: {name: 'x'})
|
|
98
|
+
</code></pre>
|
|
99
|
+
</summary>
|
|
100
|
+
</entry>
|
|
101
|
+
<entry>
|
|
102
|
+
<id>http://stackoverflow.com/questions/22717251/-/22717807#22717807</id>
|
|
103
|
+
<re:rank scheme="http://stackoverflow.com">0</re:rank>
|
|
104
|
+
<title type="text">Answer by VAIRIX for How can I display png data as an image inside in the browser?</title>
|
|
105
|
+
<author>
|
|
106
|
+
<name>VAIRIX</name>
|
|
107
|
+
<uri>http://stackoverflow.com/users/3470100</uri>
|
|
108
|
+
</author>
|
|
109
|
+
<link rel="alternate" href="http://stackoverflow.com/questions/22717251/how-can-i-display-png-data-as-an-image-inside-in-the-browser/22717807#22717807" />
|
|
110
|
+
<published>2014-03-28T16:04:58Z</published>
|
|
111
|
+
<updated>2014-03-28T16:04:58Z</updated>
|
|
112
|
+
<summary type="html"><p>One way to do this, is by doing the following:
|
|
113
|
+
In the view</p>
|
|
114
|
+
|
|
115
|
+
<pre><code>&lt;img src="/get_img/tlotr"&gt;
|
|
116
|
+
</code></pre>
|
|
117
|
+
|
|
118
|
+
<p>That will make a request to the server, so in the routes.rb add</p>
|
|
119
|
+
|
|
120
|
+
<pre><code>get '/get_img/:filename' =&gt; 'test#img'
|
|
121
|
+
</code></pre>
|
|
122
|
+
|
|
123
|
+
<p>In my case I have a TestController with an action call img like:</p>
|
|
124
|
+
|
|
125
|
+
<pre><code>def img
|
|
126
|
+
send_file( "/your_path/#{params[:filename]}.png",
|
|
127
|
+
:disposition =&gt; 'inline',
|
|
128
|
+
:type =&gt; 'image/png',
|
|
129
|
+
:x_sendfile =&gt; true )
|
|
130
|
+
end
|
|
131
|
+
</code></pre>
|
|
132
|
+
|
|
133
|
+
<p>With this solution you hit the server one more time, but you don't have to send the data using the read method.</p>
|
|
134
|
+
</summary>
|
|
135
|
+
</entry>
|
|
136
|
+
<entry>
|
|
137
|
+
<id>http://stackoverflow.com/questions/22716263/-/22716782#22716782</id>
|
|
138
|
+
<re:rank scheme="http://stackoverflow.com">0</re:rank>
|
|
139
|
+
<title type="text">Answer by VAIRIX for Use form to send ajax request to rails app</title>
|
|
140
|
+
<author>
|
|
141
|
+
<name>VAIRIX</name>
|
|
142
|
+
<uri>http://stackoverflow.com/users/3470100</uri>
|
|
143
|
+
</author>
|
|
144
|
+
<link rel="alternate" href="http://stackoverflow.com/questions/22716263/use-form-to-send-ajax-request-to-rails-app/22716782#22716782" />
|
|
145
|
+
<published>2014-03-28T15:20:09Z</published>
|
|
146
|
+
<updated>2014-03-28T15:20:09Z</updated>
|
|
147
|
+
<summary type="html"><p>You can do something like that:</p>
|
|
148
|
+
|
|
149
|
+
<p>In your javascript file:</p>
|
|
150
|
+
|
|
151
|
+
<pre><code>$('#my_button').click(function(){
|
|
152
|
+
$.ajax({
|
|
153
|
+
type:'GET',
|
|
154
|
+
url: '/table',
|
|
155
|
+
data:{ rows: $('#my_text_field').val() },
|
|
156
|
+
success: function(data){
|
|
157
|
+
$('#my_table_container').html(data);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
</code></pre>
|
|
162
|
+
|
|
163
|
+
<p>In your controller:</p>
|
|
164
|
+
|
|
165
|
+
<pre><code>def table
|
|
166
|
+
render partial: 'table', locals: { rows: params[:rows] }
|
|
167
|
+
end
|
|
168
|
+
</code></pre>
|
|
169
|
+
|
|
170
|
+
<p>In your routes.rb:</p>
|
|
171
|
+
|
|
172
|
+
<pre><code>match 'table' =&gt; 'your_controller#table'
|
|
173
|
+
</code></pre>
|
|
174
|
+
|
|
175
|
+
<p>And then in your partial (_partial.html.rb), you have to iterate over number of rows that you receive in the rows param. </p>
|
|
176
|
+
</summary>
|
|
177
|
+
</entry>
|
|
178
|
+
<entry>
|
|
179
|
+
<id>http://stackoverflow.com/questions/22715588/-/22716096#22716096</id>
|
|
180
|
+
<re:rank scheme="http://stackoverflow.com">2</re:rank>
|
|
181
|
+
<title type="text">Answer by VAIRIX for Helper for controller and views</title>
|
|
182
|
+
<author>
|
|
183
|
+
<name>VAIRIX</name>
|
|
184
|
+
<uri>http://stackoverflow.com/users/3470100</uri>
|
|
185
|
+
</author>
|
|
186
|
+
<link rel="alternate" href="http://stackoverflow.com/questions/22715588/helper-for-controller-and-views/22716096#22716096" />
|
|
187
|
+
<published>2014-03-28T14:48:22Z</published>
|
|
188
|
+
<updated>2014-03-28T14:48:22Z</updated>
|
|
189
|
+
<summary type="html"><p>Define it in the ApplicationController like:</p>
|
|
190
|
+
|
|
191
|
+
<pre><code>class ApplicationController &lt; ActionController::Base
|
|
192
|
+
|
|
193
|
+
helper_method :paypal_url
|
|
194
|
+
|
|
195
|
+
def paypal_url
|
|
196
|
+
'https://www.paypal.com/cgi-bin/webscr'
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
end
|
|
200
|
+
</code></pre>
|
|
201
|
+
|
|
202
|
+
<p>After that you'll be able to use the helper method from any view or controller.</p>
|
|
203
|
+
</summary>
|
|
204
|
+
</entry>
|
|
205
|
+
<entry>
|
|
206
|
+
<id>http://stackoverflow.com/questions/22761911/how-to-implement-root-route-and-get-index-to-the-same-page/22762973?cid=34709045#22762973</id>
|
|
207
|
+
<title type="text">Comment by VAIRIX on How to implement root route and get "index" to the same page</title>
|
|
208
|
+
<author>
|
|
209
|
+
<name>VAIRIX</name>
|
|
210
|
+
<uri>http://stackoverflow.com/users/3470100</uri>
|
|
211
|
+
</author>
|
|
212
|
+
<link rel="alternate" href="http://stackoverflow.com/questions/22761911/how-to-implement-root-route-and-get-index-to-the-same-page/22762973#22762973" />
|
|
213
|
+
<published>2014-03-31T16:45:30Z</published>
|
|
214
|
+
<updated>2014-03-31T16:45:30Z</updated>
|
|
215
|
+
<summary type="html">You can add <code>root to: &#39;static_pages#index&#39;</code> inside or outside your scope. It&#39;s a possible solution and maybe doesn&#39;t fit what you expect, cause it takes more code to solve the problem.</summary>
|
|
216
|
+
</entry>
|
|
217
|
+
|
|
218
|
+
<entry>
|
|
219
|
+
<id>http://stackoverflow.com/questions/22759923/how-to-let-the-user-create-cron-jobs-in-rails?cid=34699568</id>
|
|
220
|
+
<title type="text">Comment by VAIRIX on How to let the user create cron jobs in rails?</title>
|
|
221
|
+
<author>
|
|
222
|
+
<name>VAIRIX</name>
|
|
223
|
+
<uri>http://stackoverflow.com/users/3470100</uri>
|
|
224
|
+
</author>
|
|
225
|
+
<link rel="alternate" href="http://stackoverflow.com/questions/22759923/how-to-let-the-user-create-cron-jobs-in-rails" />
|
|
226
|
+
<published>2014-03-31T12:58:30Z</published>
|
|
227
|
+
<updated>2014-03-31T12:58:30Z</updated>
|
|
228
|
+
<summary type="html">If you want to schedule a task every X period of time, and your user only sets when and the task (as you said), you could try doing it with delayedjob ` class.delay(run_at: 5.hours.from_now).method(param)` and call recursive in the method. Of course you will have some delay of excecution (even if the first thing in your method is calling the recursion). It should be some similar way to do it with Sidekiq (really don&#39;t know). Be careful with overlapping of tasks.</summary>
|
|
229
|
+
</entry>
|
|
230
|
+
|
|
231
|
+
<entry>
|
|
232
|
+
<id>http://stackoverflow.com/questions/22716263/use-form-to-send-ajax-request-to-rails-app/22716782?cid=34623992#22716782</id>
|
|
233
|
+
<title type="text">Comment by VAIRIX on Use form to send ajax request to rails app</title>
|
|
234
|
+
<author>
|
|
235
|
+
<name>VAIRIX</name>
|
|
236
|
+
<uri>http://stackoverflow.com/users/3470100</uri>
|
|
237
|
+
</author>
|
|
238
|
+
<link rel="alternate" href="http://stackoverflow.com/questions/22716263/use-form-to-send-ajax-request-to-rails-app/22716782#22716782" />
|
|
239
|
+
<published>2014-03-28T17:57:47Z</published>
|
|
240
|
+
<updated>2014-03-28T17:57:47Z</updated>
|
|
241
|
+
<summary type="html">If you need more params from the view, just add them in the &quot;data ajax attribute&quot; like <code>data:{ rows: val1, sort: val2 }</code></summary>
|
|
242
|
+
</entry>
|
|
243
|
+
</feed>
|